GNU Readline: The Hidden Hero of Your Terminal ๐ฆธ¶
Readline is widely used but less widely understood.
Most Used Readline Commands¶
| Function Name | Shortcut | Description | ๐ญ |
|---|---|---|---|
| ๐ reverse-search-history | Ctrl-R | Search command history backwards | The ultimate history finder |
| โฌ ๏ธ beginning-of-line | Ctrl-A | Move to start of line | Faster than holding left arrow |
| โก๏ธ end-of-line | Ctrl-E | Move to end of line | Better than mashing right arrow |
| ๐ฆ forward-word | Alt-F | Move forward one word | Like Ctrl-Right in editors |
| ๐ฆ backward-word | Alt-B | Move backward one word | Like Ctrl-Left in editors |
| โ๏ธ unix-word-rubout | Ctrl-W | Delete word before cursor | Quicker than backspace |
| ๐๏ธ kill-line | Ctrl-K | Kill text from cursor to end | Perfect for rewriting commands |
| ๐ yank | Ctrl-Y | Yank previously killed text | Paste what you just cut |
| ๐งน clear-screen | Ctrl-L | Clear screen | Cleaner than typing 'clear' |
| ๐ yank-last-arg | Alt-. | Insert last arg of previous command | Great for operating on same file |
| โฉ๏ธ undo | Ctrl-_ | Undo | Everyone needs an undo! |
| ๐ insert-comment | Alt-# | Comment line & move to new line | Save that command for later |
| ๐ exchange-point-and-mark | Ctrl-XX | Toggle between start & cursor | Great for adding sudo |
| ๐ฏ character-search | Ctrl-] x | Move to next character 'x' | Quick character navigation |
| ๐ beginning-of-history | Alt-< | Move to first command in history | Jump to the beginning |
| ๐ end-of-history | Alt-> | Move to last command in history | Back to the present |
Pro Tips ๐¶
- These function names are what you'll see in the output of
bind -p - Use them in your
.inputrcfor custom bindings - They're consistent across readline-using applications
- Many have both emacs and vi mode equivalents