Bash
Editing Commands
Alt + f
: Forward (right) one wordAlt + b
: Back (left) one wordCtrl + u
: Cut/delete the Line before the cursor to the clipboardCtrl + k
: Cut the Line after the cursor to the clipboardCtrl + w
: Cut the Word before the cursor to the clipboardAlt + d
: Delete the Word after the cursorAlt + Del
: Delete the Word before the cursor.Ctrl + y
: Paste the last thing that was cut
History Commands
Ctrl + r
: searches the command history as you typeCtrl + p
: Previous command in the search result ofCtrl + r
Ctrl + n
: Next command in the search result ofCt rl + r
Alt + .
or!$
: Reuse the last argument of previous command!*
: All arguments of previous command!!
: Repeat previous command!blah
: Run last/most recent command that starts withblah
!blah:p
: Print last command starting withblah
^blah
: Deleteblah
from previous command^blah^foo
: Replaceblah
withfoo
in previous commandTo retain history across sessions, you need to add the
PROMPT_COMMAND='history -a ~/.bash_history'
to your.bash_profile
then close and reopen all bash sessions
Last updated