Stop Holding Backspace: 10 Shell Shortcuts for Prompting AI Agents

Ten keyboard shortcuts your shell already supports can make writing prompts for AI agents in the terminal much faster. You don’t need to install anything or change a setting.

Prompts for CLI agents are often long. A small typo near the start of a two-line prompt usually means holding Backspace, or reaching for the mouse and clicking in the right spot. Both are slow. The shortcuts below come from readline, the line editor behind Bash, and zsh uses the same keys by default. Many interactive agent sessions, including Claude Code, support most of them in their prompt input too.

The video below shows each shortcut in about five seconds.

Delete text without holding Backspace

Ctrl + W deletes the word before the cursor. Typed tets instead of test? One press removes the whole word, and you type it again.

Ctrl + U deletes everything from the cursor back to the start of the line. It is the fastest way to throw away a command you no longer want, like an rm -rf you had second thoughts about.

Ctrl + K is the mirror of Ctrl + U. It deletes everything from the cursor to the end of the line, which is handy for dropping a tail of flags such as --model opus --verbose.

The text these three shortcuts delete is not gone. The shell keeps it, so you can paste it back later (see Ctrl + Y below).

Move the cursor without the arrow keys

Ctrl + A jumps to the start of the line. Forgot to cd into the right folder first? Jump back, type cd api && , and you’re done.

Ctrl + E jumps to the end of the line, so you can add a flag or finish a sentence after a fix in the middle.

Alt + B moves back one word, and Alt + F moves forward one word. Together they let you hop to the middle of a long prompt, change one word, and hop on, instead of tapping the arrow key forty times.

Paste, search, and cancel

Ctrl + Y pastes back the last text you deleted with Ctrl + W, Ctrl + U, or Ctrl + K. My favourite use: you’re halfway through a long prompt and realise you need to run git status first. Press Ctrl + U to park the prompt, run the command, then press Ctrl + Y to bring the prompt back. Nothing to retype.

Ctrl + R searches your command history backward. Type a few letters, like dep, and the shell finds the most recent command that contains them, such as npm run deploy:staging. Press Enter to run it, or keep pressing Ctrl + R to step through older matches.

Ctrl + C cancels the current input or the running command. When an agent heads the wrong way, like starting to rewrite your whole codebase, Ctrl + C stops it.

Quick reference

Shortcut What it does
Ctrl + W Delete the previous word
Ctrl + U Delete from the cursor to the start of the line
Ctrl + K Delete from the cursor to the end of the line
Ctrl + A Jump to the start of the line
Ctrl + E Jump to the end of the line
Alt + B Move back one word
Alt + F Move forward one word
Ctrl + Y Paste back text deleted with Ctrl + W, U, or K
Ctrl + R Search command history backward
Ctrl + C Cancel the current command or input

A few things to know:

Make them muscle memory

You don’t need all ten on day one. Start with Ctrl + W, Ctrl + A, and Ctrl + E, and add the others once those feel natural. After a week or two, editing a long prompt in the terminal feels much faster than it used to.

Did I miss a shortcut you use every day? Share it in the comments below.