Skip to content

Instantly share code, notes, and snippets.

@francisrstokes
Forked from 2KAbhishek/Shell_Keybindings.md
Created December 13, 2024 10:04
Show Gist options
  • Save francisrstokes/66d477e493d9943fef31e3f02fdc537d to your computer and use it in GitHub Desktop.
Save francisrstokes/66d477e493d9943fef31e3f02fdc537d to your computer and use it in GitHub Desktop.
Keyboard shortcuts for bash/zsh

Shell Keybindings

Navigation ๐Ÿš€

Keybinding Action
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 โœ๏ธ

Keybinding Action
Alt + . or !$ Previous commands last argument
Alt + c Capitalize word
Alt + d Delete next word
Alt + Del Delete previous word
Alt + l/u Lowercase/Uppercase word
Alt + r Cancel the changes, revert
Alt + t Swap current word with previous
Alt + w Delete until beginning (zsh)
Ctrl + _ Undo
Ctrl + k Cut till end
Ctrl + t Swap the last two characters before the cursor
Ctrl + u Delete whole line (zsh)/ cut until beginning (bash)
Ctrl + w Cut previous word
Ctrl + x,e Open command in editor
Ctrl + y Paste
Esc + t Swap the last two words before the cursor
!* All arguments of previous command

Process ๐Ÿ“Š

Keybinding Action
Ctrl + c Interrupt/Kill
Ctrl + d Close current shell
Ctrl + l Clear screen
Ctrl + z Background/Foreground job

History โณ

Keybinding Action
Ctrl + r History search
Ctrl + s Go back to the next most recent command
^abc^def Run previous command, replacing abc with def

Modes ๐Ÿ•น๏ธ

Keybinding Action
Ctrl + x,v vi mode (zsh)
bindkey -e Emacs mode
set -o vi / bindkey -v Vi mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment