GNU Readline: Useful Command Line Navigation Tools

Most varieties of Unix/Linux use GNU Readline which lets you edit commands on the command line, gives you a command-line history, handles tab-completion, and the like.

Many of the basic commands are pretty obvious: you use the left/right arrow keys to move your cursor. Up/down arrow keys scroll through the saved command history.

Some, however, extremely useful, but are a bit more esoteric. Remmeber that C means the 'Control' key, and M means the 'Meta' key, which is usually Option (OS X) or ALT (Windows).

C-a - move to the beginning of the line.
C-e - move to the end of the line
M-b - move back one word (incidentally, C-f is forward a character, but you have arrow keys for that)
M-f - move forward one work
C-] + character - move forward to the next instance of character M-C-] + character - same, but move backwards

Finally, there are some really esoteric commands. Generally, I don't find it that worthwhile to learn these, but Peter Krumins has put together a GNU Readline cheat sheet with all the gory details. He's also got a good article that covers a few of the more advanced concepts.

server-tech/gnu-readline-useful-command-line-shortcuts.txt · Last modified: Nov 10, 2008 10:18 PM by dordal
© 2005-10 David Ordal / DO IT, LLC. All Rights Reserved.