DEV Community

Abhishek Keshri
Abhishek Keshri

Posted on • Originally published at on

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.

Shell Keybindings

Navigation πŸš€

Alt + f/b - Move cursor to previous/next word

Ctrl + a/e - Move cursor to beginning/end of command

Ctrl + xx - Toggle between the start of line and current cursor position

Editing ✏️

Ctrl + x,e - Open command in editor

Ctrl + k - Cut till end

Ctrl + u - Delete whole line (zsh)/ cut until beginning (bash)

Alt + w - Delete until beginning (zsh)

Alt + l/u - Lowercase/Uppercase word

Alt + c - Capitalize word

Ctrl + w - Cut previous word

Alt + Del - Delete previous word

Alt + d - Delete next word

Alt +. or !$ - Previous commands last arguement

!* - All arguments of previous command

Alt + t - Swap current word with previous

Ctrl + t - Swap the last two characters before the cursor (typo).

Esc + t - Swap the last two words before the cursor

Ctrl + y - Paste

Ctrl + _ - Undo

Alt + r - Cancel the changes, revert

Process πŸ“Š

Ctrl + l - Clear screen

Ctrl + c - Interrupt/Kill

Ctrl + d - Close current shell

Ctrl + z - Background/Foreground job

History ⏳

Ctrl + r - History search

Ctrl + s - Go back to the next most recent command

^abcΒ­^Β­def - Run previous command, replacing abc with def

Modes πŸ•ΉοΈ

Ctrl +x,v - vi mode (zsh)

set -o vi - Vi mode

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

GitHub gist here.

Discussion (2)

ianturton profile image
Ian Turton

you might want to add ctrl-q to restart the shell output after ctrl-s or people are going to end up stuck

2kabhishek profile image
Abhishek Keshri Author

I have removed ctrl + s as it's already being used for search.
Thank you for your suggestion.