D   A   T   A   W   O   K

Creation: February 08 2016
Modified: September 11 2018

Bash Shortcuts

The bash shell has a very rich set of conveninent shortcuts. This ability to edit the command line is provided by the GNU Readline library. Readline keybindings are taken from the Emacs text editor.

Moving the cursor

C-a Go to the beginning of the line (begin)
C-e Go to the end of the line (end)
C-b Back one character (left arrow)
C-f Forward one character (right arrow)
A-b Backward one word
A-f Forward one word
C-xx Toggle between two positions. The second one is initially set as the start of line


C-l Clear the screen, similar to the clear command
A-Del Cut the word before the cursor (excluded)
A-d Cut the word after the cursor (included)
C-h Delete character before the cursor
C-d Delete character under the cursor
C-w Cut the word before the cursor
C-k Cut the line after the cursor (included)
C-u Cut the line before the cursor (excluded)
C-y Paste the last cutted thing being cut (yank)
A-t Swap current word with previous
C-t Swap the character under the cursor with the previous one
A-c Capitalize the character under the cursor and move to end of word
A-u Makes uppercase from cursor to end of word
A-l Makes lowercase from cursor to end of word
C-_ Undo
`A-r Cancel the changes and restore the original line
Tab Completion for file/directory names


C-r Recall a previous command. Keep searching backward for matches by pressing C-r again
C-p Previous command in history (up arrow)
C-n Next command (down arrow)
C-s Go back to the most recent command
C-o Execute the command found via C-r or C-s
C-g Escape from history searching mode
!! Repeat the last command
!abc Run the last command starting with abc
!abc:p Print the last command starting with abc
!$ Last argument of previous command
!$:p Print the last argument of previous command
!\* All arguments or the previous command
!\*:p Print all arguments or the previous command
^ab^cde Run previous command, replacing ab with cde

Process control

C-c Interrupt/kill the current foreground running program (SIGINT)
C-z Stop/sleep the current running foreground program
C-d EOF, close the terminal
C-s Stops output to the screen
C-q Allows output to the screen

Enable Vi mode

To use Vi mode in Bash and any other tool that uses GNU Readline, you need only to put this into your .inputrc file.

set editing-mode vi

If you only want to use this mode in Bash, an alternative is to use the following in your .bashrc file.

set -o vi