Nowadays, I spend more time in Bash shell, typing longer commands. One of my new year resolutions for this year is to stop using left/right arrow keys to move around in the command line. I learned a few shortcuts a while ago.
Last night, I spent some time to read about “Command Line Editing” in the bash manual. The bash manual is a well-written piece of documentation. I think I should read it more often.
Well, here’s the new shortcuts I learned:
- Move back one character.
- Move forward one character.
- Delete current character.
- Delete previous character.
- Move to the start of line.
- Move to the end of line.
- Move forward a word.
f(a word contains alphabets and digits, no symbols)
- Move backward a word.
- Clear the screen.
What is Meta?
Meta is your
Alt key, normally. For Mac OSX user, you need to
enable it yourself. Open Terminal > Preferences > Settings > Keyboard,
and enable Use option as meta key.
Meta key, by convention, is used for operations on word.
Cut and paste (‘Kill and yank’ for old schoolers)
- Cut from cursor to the end of line.
- Cut from cursor to the end of word.
- Cut from cursor to the start of word.
- Cut from cursor to previous whitespace.
- Paste the last cut text.
- Loop through and paste previously cut text.
y(use it after
- Loop through and paste the last argument of previous commands.
Search the command history
- Search as you type.
rand type the search term; Repeat
rto loop through results.
- Search the last remembered search term.
- End the search at current history entry.
- Cancel the search and restore original line.