Reputation: 17325
I would like to move between the command line arguments in a fast way. For example, if I have the following command line:
> do_something_with /very_long_path/to_a_very_long_directory/ more_args
^ ^
I would like to skip the whole path (jump between the ^ symbols). I'm already familiar with word mode (Alt+B and Alt+F) but in some scenarios it's not enough to navigate quickly between the arguments.
Upvotes: 0
Views: 769
Reputation: 101
For vi/vim users ctrl+] + char
can be used to quickly navigate to the first occurance of a given char. Which is equivalent to f + char
in vi/vim.
Upvotes: 0
Reputation: 52112
There are (quote from manual)
shell-forward-word ()
Move forward to the end of the next word. Words are delimited by non-quoted shell metacharacters.
and
shell-backward-word ()
Move back to the start of the current or previous word. Words are delimited by non-quoted shell metacharacters.
I have bound them to Ctrl+Alt+F and Ctrl+Alt+B by adding this to my .inputrc
:
"\e\C-f": shell-forward-word
"\e\C-b": shell-backward-word
Upvotes: 1
Reputation: 753
In bash, you can set the cursor to the previous given character using the following features:
character-search
and character-search-backward
features.
ctrl+], (resp. alt+ctrl+]) + searched_character
In your example, you can search backward for a space.
> do_something_with /very/long/path/\ with_spaces\ directory/ more_args
^ ^
Unfortunately, this will not work so well with paths like:
> do_something_with /very_\ long_path/to_a_\ very_long_directory/ more_args
As a sidenote, you can use ctrl+a and ctrl+e to go at the beginning / end of a line.
Upvotes: 2