Shortcuts to Move Faster in Bash Command Line
teohm.github.com
teohm.github.com
Put the following in your ~/.inputrc
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
set show-all-if-ambiguous on
set completion-ignore-case on
Now if you type, say: cat <UP ARROW>
You will cycle through commands in your history that start with the prefix "cat ". set -o vi
to ~/.bashrc.Peteris Krumins also has an article on bash command line editing with some extra information on completion:
http://www.catonmat.net/blog/bash-emacs-editing-mode-cheat-s...
I haven't actually put the set into my .bashrc yet, I just end up typing it when I realize I'm about to navigate a lot.
> ls /etc/foo/bar
and have my cursor at the end when I realize I want to type ls -l instead. I know there's got to be a faster way than what I'm currently doing, but I'm blanking.
(Yes, I know sometimes tacking on the command line switch at the end will work, but that's not true for all commands).
You can hit `;` if there are multiple incidences of 's'.
that should work for commands without spaces in them.
I remap jj to escape so it is faster than moving my hand.
in ~/.inputrc
set editing-mode vi
$if mode=vi
#normal mode
set keymap vi-insert
"jj": vi-movement-mode
$endifIn zsh you still have the opportunity to inspect it once more when you leave the editor, and it maintains it's multiline format in the history.
If I was previously sitting in directory:
'/home/user/code/github.com/cookbooks/cassandra/recipes'
and I wanted to jump back to that dir from anywhere on the file system I could just type 'j cass rec' and it would autocomplete and jump to this location. Super helpful.
$if Bash
# various other stuff left out
# easier back and forth by word
"\C-b": backward-word
"\eb": backward-char
"\C-f": forward-word
"\ef": forward-char
$endif
For more examples and syntax, see http://docs.freebsd.org/info/readline/readline.info.Sample_I... and http://docs.freebsd.org/info/readline/readline.info.Readline....By default, option does what it does in other programs, allowing you to type alternative characters. If you'd still like to keep that behaviour, you can send meta by pressing escape first -- Meta-b becomes escape, then b.
http://samrowe.com/wordpress/advancing-in-the-bash-shell/ is a good list of extra tips
http://www.skorks.com/2009/09/bash-shortcuts-for-maximum-pro...
which includes some other nice shortcuts - like ctrl + xx
Also, 'Ctrl + p' and 'Ctrl + n' will navigate through your command history. I do love 'Ctrl + r' for searching through it, too.