Shortcuts to Move Faster in Terminal¶
Nowdays we spend a lot of time in bash shell, typing long and complex commands. You can use the arrow keys up/down/left/right
to move the cursor and select commands, but that's not so efficient.
By default, bash command line uses the shortcuts of emacs
, so the following commands are mostly from emacs
, you can also use the shortcuts of vim
by setting set -o vi
.
Move¶
Move in Charactor¶
C-b
: Moveback
one charactor(C
is forCtrl
)C-f
: Moveforward
one charactor
Move in Word¶
A-f
: Moveforward
a word(A
is forAlt
)A-b
: Movebackward
a word
Move in Line¶
C-a
: Move to theahead
of the lineC-e
: Move to theend
of the line
Edit¶
Cut in Charactor¶
C-d
:Delete
current charactorBackspace
: Delete previous charactorC--
: Undo
Cut in Word¶
A-d
: Cut from cursor to the end of wordA-Backspace
: Cut from cursor to the start of wordC-w
: Cut from cursor to previous whitespace
Cut in Line¶
C-k
: Cut(kill
) from cursor to the end of lineC-x-Backspace
: Cut from cursor to the start of line
Paste¶
C-y
: Paste(yank
) the last cut textA-y
(afterC-y
): Redo pasting the last cut text
Transpose¶
C-t
:Transpose
the charactor under the cursor and the one before itEsc-t
: Transpose the word under the cursor and the one before it
Search¶
C-p
: Retrieve theprevious
commandC-n
: Retrieve thenext
commandC-s
: Forwardsearch
C-r
:Reverse
searchC-g
: Quit the search mode
Replace(The bang !
commands)¶
!!
: Excute last command!top
: Excute the most recent command that starts withtop
!$
: Excute the last word of the previous command!*
: Excute the all words of the previous command except the first![pattern]:p
: Display the!
command result