Show Menu
Cheatography

Better Bash Keyboard Shortcuts (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

movement

ctrl + a
go to start of line
ctrl + e
go to end of line
ctrl + xx
go to start of line, press again to go back to starting position
alt + b
go back one word
alt + f
go forward one word
ctrl + b
go back one character
ctrl + f
fo forward one character

history

ctrl + r
search history backward
ctrl + s
search history forward*
ctrl + g
quit search mode
ctrl + p
previous command (same as )
ctrl + n
next command (same as )
ctrl + o
run current command from history, then queue next command in history
alt + .
insert last word of previous command (addit­ional presses cycle back through history)
* ctrl + s by default will stop output from the shell, but this is a termin­al-­level feature which blocks this command from reaching the shell
* run
stty -ixon
to disable to terminal feature, place in
~/.bashrc
to make permanent
 

control

ctrl + l
clear screen
ctrl + s
pause screen output
ctrl + q
unpause screen output
ctrl + z
suspend program (use
fg
to unsuspend)

manipu­lation

alt + c
captialize to end of word (make current char uppercase, remainder of word lowercase)
alt + u
from cursor, uppercase to end of word
alt + l
from cursor, lowercase to end of word
alt + t
transpose word with previous word (space counts as the next word)
ctrl + _ OR ctrl + 7 OR ctrl +x ctrl + u
undo last edit (can be used repeat­edly)
ctrl + x ctrl + e
open the current command line in your editor*
* specify desired editor by setting $EDITOR or $VISUAL enviro­nment variables
* when editing the command line in vi-like editor, quit with
:cq
to avoid running the command, otherwise exit with
:wq
or
:x
as usual
* the shell might not recognise a GUI editor properly, since some spawn the process and then exit
 

cut/pa­ste­/delete

ctrl + u
from cursor, delete to start of line
ctrl + k
from cursor, delete to end of line
ctrl + w
from cursor, delete to start of word
alt + d
from cursor, delete to end of word
ctrl + d
delete current character (delete key)
ctrl + h
delete character before cursor (backs­pace)
ctrl + y
paste cut/de­leted text after cursor

bang

!!
run last whole command
!foo
run last command starting with "­foo­"
!?foo?
run last command containing foo
!$
replaced with last word of previous command (same as
alt + .
but doesn't put the actual text)
!*
replaced with all arguments of previous command
<bang cmd>:p
print what <bang cmd> would be replaced with/run
<bang cmd>:s­/fo­o/bar
replace foo with bar in command returned by <bang cmd> (use sed search­/re­place format)