Kolam Ayer MakersLinux Foundations

Readline

Readline is the line-editing library that gives Bash prompts many of their movement, editing, search, and history keystrokes.

Movement

Keys Action
Ctrl-A Move to start of line.
Ctrl-E Move to end of line.
Alt-B Move back one word.
Alt-F Move forward one word.
Ctrl-XX Toggle between current cursor position and start of line.

Editing

Keys Action
Ctrl-U Cut from cursor to start of line.
Ctrl-K Cut from cursor to end of line.
Ctrl-W Cut the word before the cursor.
Alt-D Cut the word after the cursor.
Ctrl-Y Paste the last cut text.
Ctrl-T Swap the two characters before the cursor.
Alt-T Swap the two words around the cursor.
Alt-U Uppercase from cursor to end of word.
Alt-L Lowercase from cursor to end of word.
Alt-C Capitalize from cursor to end of word.

History

Keys Action
Up Previous command.
Down Next command.
Ctrl-R Reverse-search command history.
Ctrl-G Cancel history search.
Ctrl-P Previous history entry.
Ctrl-N Next history entry.

Completion And Control

Keys Action
Tab Complete command, path, variable, or option when possible.
Tab Tab Show possible completions.
Ctrl-C Interrupt the foreground command.
Ctrl-D Send end-of-file; at an empty prompt, usually log out.
Ctrl-L Clear the screen like clear.

Muscle Memory Drills

Type this line, but do not press Enter:

grep -R makers ~/src/pages > ~/playground/matches.txt

Drill it:

  1. Press Ctrl-A, add time , then press Ctrl-E.
  2. Press Alt-B until the cursor reaches makers, then change it to another word.
  3. Press Ctrl-K, then Ctrl-Y to cut and restore the redirect.
  4. Press Ctrl-U, then Ctrl-Y to cut and restore the whole command prefix.
  5. Press Ctrl-C to cancel instead of running the practice line.

Shell Ninja Habits

Docs Pointers