Show Menu

Command Line Editing in Bash Keyboard Shortcuts by

Command line editing in GNU bash version 3, emacs mode
bash     command     shortcuts     keyboard     vi     shell

Key Map

M,
Meta key, usually Esc. Press and release key.
C+
Ctrl key. Hold and press key(s) that follow.
A+
Alt key. Hold and press key(s) that follow.
C+a
Home
Action w/multiple shortcuts, each on separate lines.
Ex: C+a is one option, Home is another.

Command History

hist­ory [n]
Display history (last n lines)
C+p
UpArrow
Display previous line in history
C+n
DownArrow
Display next line in history
C+­r(­C+r)
Reverse search
C+r again will display previous match in history
C+g
Esc
Exit history search mode
C+o
Execute the command found via C+r or C+s
!!
Execute last command
!abc
Execute last command that starts with abc
^abc­def
Execute previous command, replacing abc with def
!­abc:p
Print last command that starts with abc
M,.(­M,.)
Print last argument from previous command
M,. again will display last argument from previous command in history
!$
Variable which contains the last argument of the previous command
!*
Variable which contains all arguments of the previous command

Editing

C+h
Backspace
Delete the character to the left of the cursor
Del
Delete the character to the right of (under) the cursor
On an empty line, C+d exits the current shell
M,C+h
M,Backspace
Cut the word to the left of the cursor
C+d
M,d
Cut the word to the right of the cursor
C+u
Cut all characters to the left of the cursor
C+k
Cut all characters to the right of the cursor
C+y
Paste word or text that was cut using one of the deletion shortcuts
M,l
Convert the next word to lower case
M,u
Convert the next word to UPPER CASE
M,c
Convert the next word to Proper Case
C+t
Transpose the two characters on either side of the cursor and move right
M,t
Transpose the two words on either side of the cursor and move right
C+vx
Insert x literally, even if x is a special character
C+_
Revert­/Undo previous edit
M,r
Revert­/Undo all edits
 

Expansion

M,C+e
Expand the current line as the shell would before execution
C+iC+i
Tab
If on first word of line, complete the command name.
If not on first word of line, complete the file name.
C+i
TabTab
Show possible comman­d/file name comple­tions

Download the Command Line Editing in Bash Keyboard Shortcuts

1 Page
//media.cheatography.com/storage/thumb/drstrangepork_command-line-editing-in-bash.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Bash Keyboard Shortcuts
          bash Shortcuts Cheat Sheet

          More Cheat Sheets by DrStrangepork

          ICAO Alphabet Cheat Sheet