shortcutsguide

Move to Beginning of Line in Terminal (Ctrl+A)

Press Ctrl+A to jump the cursor to the very start of the current command line — the same key in bash and zsh on macOS, Linux and Windows (WSL / Git Bash).

ActionMacWindows
Move to beginning of line Ctrl+A Ctrl+A
Move to end of line Ctrl+E Ctrl+E
Move back one word ⌥B / Esc then B Alt+B
Move forward one word ⌥F / Esc then F Alt+F
Move back one character Ctrl+B Ctrl+B

Jump to the start of the line

In any readline shell — bash or zsh — press Ctrl+A to move the cursor to the beginning of the command line. This works the same on macOS Terminal, Linux, and Windows WSL / Git Bash, because they all use the GNU readline (or zsh emacs-mode) keymap. It is not ⌘← — the readline shortcut is the Control key.

Pair it with Ctrl+E

Ctrl+A goes to the start, Ctrl+E goes to the end. Together they let you fix a long command without reaching for the arrow keys or the mouse. To move word-by-word use Alt+B / Alt+F (on macOS Terminal enable "Use Option as Meta key", or press Esc then the letter).

If Ctrl+A does nothing

If you are in vi editing mode (set -o vi), Ctrl+A may not move to the start — press Esc then 0. In tmux or screen, Ctrl+A is the prefix key, so press it twice (Ctrl+A A) to send a literal Ctrl+A to the shell.

FAQ

How do I move to the start of the line in a terminal?

Press Ctrl+A in bash or zsh. The cursor jumps to the beginning of the command line. It is the same on macOS, Linux and Windows WSL/Git Bash.

Is it Ctrl+A or Cmd+Left on Mac?

In the shell it is Ctrl+A (readline). ⌘← is a text-field shortcut in GUI apps, not in the terminal command line.

Why doesn't Ctrl+A work in tmux?

Ctrl+A is tmux's default prefix key. Press Ctrl+A twice to send a literal Ctrl+A, or move to start with Ctrl+A A.

Does this work in zsh?

Yes, zsh in emacs keymap (the default) uses the same Ctrl+A. In vi mode press Esc then 0.