Skip to main content
  1. Posts/

Bash Emacs-style Shortcut Cheatsheet

··178 words·1 min·
Table of Contents

In Bash shell, when editting in the command line. There are two different modes, vi mode or Emacs mode. Emacs-mode is the default mode. Below are some of the handy shortcuts in Emacs-mode.


  • ALT-b and ALT-f: go backward(toward begining of the line)/forward (toward end of the line) a word. Note that - is a word separator in this case.
  • Ctrl-D: delete one character to the right of the cursor.
  • Ctrl-A and Ctrl-E: go to begining/end of the line.
  • Ctrl-K and Ctrl-U: delete till the end/begining of the line.
  • Ctrl-R: search history command. Press Enter to run a command, or press movement key to edit it.
  • ALT-D: Delete from current cursor position to the end of the word.
  • Ctrl-_: Undo edit.
  • ALT-R: Revert command to original.
  • Ctrl-W: Delete a word backward. Note that here word is separate by space. So if we have python util/| (| indicate cursor) , pressing Ctrl-W leave us with only python . - is not a word separator in this case. A little inconsistent, IMHO.



Creating Beautiful Bash Prompts
·403 words·2 mins
Why Cannot I Get the Value of A Env Variable in Python?
··678 words·4 mins
Bash Script Note 1
··445 words·3 mins