Skip to content

Instantly share code, notes, and snippets.

@RolandWarburton
Last active April 9, 2025 22:48
Show Gist options
  • Save RolandWarburton/acdf573eb7f074c0d28e11cf1cc8b835 to your computer and use it in GitHub Desktop.
Save RolandWarburton/acdf573eb7f074c0d28e11cf1cc8b835 to your computer and use it in GitHub Desktop.
navigating Zsh and Bash cheat sheet!

Start and end of line

  1. Ctrl+A or Home: Go to the beginning of the line.
  2. Ctrl+E or End: Go to the end of the line. Zsh Bindings:
    bindkey "^[[H" beginning-of-line
    bindkey "^[[F" end-of-line

Start and end of line

  1. Alt+F: Go right (forward) one word.
  2. Alt+B: Go left (back) one word.

Zsh Bindings:

shift-arrow() {
  ((REGION_ACTIVE)) || zle set-mark-command
  zle $1
}
shift-left() shift-arrow backward-char
shift-right() shift-arrow forward-char
zle -N shift-left
zle -N shift-right

bindkey $terminfo[kLFT] shift-left
bindkey $terminfo[kRIT] shift-right

Cutting and Pasting

  1. Ctrl+W: Cut word before cursor.
  2. Ctrl+K: Cut rest of the line after cursor.
  3. Ctrl+U: Cut rest of line before cursor.
  4. Ctrl+Y: Paste ("yank") the last cut from the clipboard.

Recalling/Searching commands

  1. Ctrl+R: Search a command.
  2. Ctrl+O: Run a command you found with Ctrl+R.
  3. Ctrl+G: Exit searching for a command.

See terminal escape sequences

ctrl+v, <any key> will show you the sequence code. Useful for creating more zsh keybinds.
Example: ctrl+V, upKey

Delete entire line

ctrl+q
ctrl+u

Delete word

ctrl+w

Swap last 2 words

alt+t no idea why you would ever need this

Clear the screen (avoid typing 'clear')

ctrl+l

Other things

  • Ctrl+F: Go right (forward) one character.
  • Ctrl+B: Go left (back) one character.
  • ctrl+XX: Move between the beginning of the line and the current position of the cursor. This allows you to press Ctrl+XX to return to the start of the line, change something, and then press Ctrl+XX to go back to your original cursor position.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment