Must-Know Bash & Zsh Keyboard Shortcuts

Jun 30, 2026

Many command-line shells (like Bash and Zsh) use the GNU Readline library to handle input. This means you have a powerful set of keyboard shortcuts at your disposal to edit, delete, and navigate long commands without using the arrow keys.

In this deep dive, we’ll cover standard shortcuts, how to enable Vim-style editing in your shell, and how to customize shortcuts using ~/.inputrc.


1. The Standard Emacs-Style Bindings (Default)

By default, most shells boot up in Emacs mode. These shortcuts work in almost every Unix terminal.

Cursor Navigation

Editing & Deleting Text

History Navigation


2. Going Modal: Enabling Vim Mode in the Shell

If you are a Vim or Neovim user, you can configure your shell to use Vim keybindings directly on the command line. This allows you to toggle between Insert Mode (for typing) and Normal Mode (for navigating, deleting, and editing using Vim keys).

In Bash:

To enable Vim editing mode in your current session:

set -o vi

To make this change permanent, add set -o vi to your ~/.bashrc file.

In Zsh:

To enable Vim editing mode in Zsh, add this to your ~/.zshrc:

bindkey -v

How it works:


3. Customizing Shortcuts with .inputrc

The GNU Readline library is configured via a file in your home directory called ~/.inputrc. You can use this file to bind custom key sequences to specific shell actions.

Here is a recommended ~/.inputrc configuration to supercharge your terminal:

# ~/.inputrc

# Enable case-insensitive tab completion
set completion-ignore-case on

# List completion matches immediately instead of double-tabbing
set show-all-if-ambiguous on

# Bind Up and Down arrow keys to search history matching what you already typed
"\e[A": history-search-backward
"\e[B": history-search-forward

# Bind Ctrl+Backspace to delete the previous word
"\e[3;5~": kill-word

To apply changes to .inputrc immediately without restarting your shell, run:

bind -f ~/.inputrc

Keybinding Quick Reference (Emacs Mode)

Category Shortcut Description
Navigation Ctrl + a Move cursor to beginning of line
Ctrl + e Move cursor to end of line
Alt + b / f Move cursor backward / forward one word
Deletion Ctrl + u Delete from cursor to start of line
Ctrl + k Delete from cursor to end of line
Ctrl + w Delete previous word
Alt + d Delete next word
Recovery Ctrl + y Paste last deleted snippet
Ctrl + _ Undo last action
History Ctrl + r Search command history
Alt + . Insert last argument of previous command