Must Know Shell Keybindings 🐧🐚

A shell also known as the command line is one of the most important tools for any software developer. You can do very complex things very quickly here. Learning to use the shell efficiently can make your life much easier.

In this post I’ll be writing about the most useful keybindings for the bash and zsh shells. *nix systems generally ship with the Bourne again shell or bash and zsh or Z shell is also quite popular among developers as it provides some very powerful features. Some of these shortcuts may work with other shells too.

KeybindingAction
Alt + f/bMove cursor to previous/next word
Ctrl + a/eMove cursor to beginning/end of command
Ctrl + xxToggle between the start of line and current cursor position

Editing ✏ī¸

KeybindingAction
Alt + . or !$Previous commands last argument
Alt + cCapitalize word
Alt + dDelete next word
Alt + DelDelete previous word
Alt + l/uLowercase/Uppercase word
Alt + rCancel the changes, revert
Alt + tSwap current word with previous
Alt + wDelete until beginning (zsh)
Ctrl + _Undo
Ctrl + kCut till end
Ctrl + tSwap the last two characters before the cursor
Ctrl + uDelete whole line (zsh)/ cut until beginning (bash)
Ctrl + wCut previous word
Ctrl + x,eOpen command in editor
Ctrl + yPaste
Esc + tSwap the last two words before the cursor
!*All arguments of previous command

Process 📊

KeybindingAction
Ctrl + cInterrupt/Kill
Ctrl + dClose current shell
Ctrl + lClear screen
Ctrl + zBackground/Foreground job

History âŗ

KeybindingAction
Ctrl + rHistory search
Ctrl + sGo back to the next most recent command
^abc^defRun previous command, replacing abc with def

Modes 🕹ī¸

KeybindingAction
Ctrl + x,vvi mode (zsh)
bindkey -eEmacs mode
set -o vi / bindkey -vVi mode

If you know any other useful keybindings, feel free to comment below.

You can find the original GitHub gist here.

Navigating JavaScript 🤷‍♂ī¸đŸ§­

Two Factor Authentication 🔏👤