Bash快捷键列表

Ref Bash Shortcuts

Bash Shortcuts#

visual cheetsheet

Moving#

commanddescription
ctrl + aGoto BEGINNING of command line
ctrl + eGoto END of command line
ctrl + bmove back one character
ctrl + fmove forward one character
alt + fmove cursor FORWARD one word
alt + bmove cursor BACK one word
ctrl + xxToggle between the start of line and current cursor position
ctrl + ] + xWhere x is any character, moves the cursor forward to the next occurance of x
alt + ctrl + ] + xWhere x is any character, moves the cursor backwards to the previous occurance of x

Edit / Other#

commanddescription
ctrl + dDelete the character under the cursor
ctrl + hDelete the previous character before cursor
ctrl + uClear all / cut BEFORE cursor
ctrl + kClear all / cut AFTER cursor
ctrl + wdelete the word BEFORE the cursor
alt + ddelete the word FROM the cursor
ctrl + ypaste (if you used a previous command to delete)
ctrl + icommand completion like Tab
ctrl + lClear the screen (same as clear command)
ctrl + ckill whatever is running
ctrl + dExit shell (same as exit command when cursor line is empty)
ctrl + zPlace current process in background
ctrl + _Undo
ctrl + x ctrl + uUndo the last changes. ctrl+ _ does the same
ctrl + tSwap the last two characters before the cursor
esc + tSwap last two words before the cursor
alt + tswap current word with previous
esc + .
esc + _
alt + [Backspace]delete PREVIOUS word
alt + <Move to the first line in the history
alt + >Move to the end of the input history, i.e., the line currently being entered
alt + ?display the file/folder names in the current path as help
alt + *print all the file/folder names in the current path as parameter
alt + .print the LAST ARGUMENT (ie "vim file1.txt file2.txt" will yield "file2.txt")
alt + ccapitalize the first character to end of word starting at cursor (whole word if cursor is at the beginning of word)
alt + umake uppercase from cursor to end of word
alt + lmake lowercase from cursor to end of word
alt + n
alt + pNon-incremental reverse search of history.
alt + rUndo all changes to the line
alt + ctl + eExpand command line.
~[TAB][TAB]List all users
$[TAB][TAB]List all system variables
@[TAB][TAB]List all entries in your /etc/hosts file
[TAB]Auto complete
cd -change to PREVIOUS working directory

History#

commanddescription
ctrl + rSearch backward starting at the current line and moving 'up' through the history as necessary
crtl + sSearch forward starting at the current line and moving 'down' through the history as necessary
ctrl + pFetch the previous command from the history list, moving back in the list (same as up arrow)
ctrl + nFetch the next command from the history list, moving forward in the list (same as down arrow)
ctrl + oExecute the command found via Ctrl+r or Ctrl+s
ctrl + gEscape from history searching mode
!!Run PREVIOUS command (ie sudo !!)
!viRun PREVIOUS command that BEGINS with vi
!vi:pPrint previously run command that BEGINS with vi
!nExecute nth command in history
!$Last argument of last command
!^First argument of last command
^abc^xyzReplace first occurance of abc with xyz in last command and execute it

Kill a job#

n = job number, to list jobs, run jobs

kill %n

Example:

kill %1

References#

  1. http://cnswww.cns.cwru.edu/php/chet/readline/readline.html
  2. https://github.com/fliptheweb/bash-shortcuts-cheat-sheet/blob/master/README.md