Nano, zsh, and bash keyboard shortcuts
Date: 2025 11-November 20
That is a great list of commands! However, the list you provided is the default key binding menu for the nano text editor, not the Bash (or Zsh) command line shell.
You can tell because it includes commands like "Write Out," "Justify," and "To Bracket," which only make sense inside an editor.
The command line (Bash/Zsh) uses a different set of keybindings, mostly derived from the GNU Readline library, which is what processes your input before the shell executes it.
Here is a comprehensive cheat sheet for the Bash/Zsh Command Line, focusing on the most useful editing, movement, and history commands (including copy, paste, and undo):
💻 Essential Bash/Zsh Command Line Shortcuts
These shortcuts use the Readline bindings and work in both Bash and Zsh.
1. Cursor Movement & Positioning
| Action | Control Key | Alt / Meta Key | Description |
|---|---|---|---|
| Beginning of Line | Ctrl+A |
Jumps the cursor to the start of the current line. | |
| End of Line | Ctrl+E |
Jumps the cursor to the end of the current line. | |
| Forward Word | Alt+F (or Esc then F) |
Moves the cursor forward one full word. | |
| Backward Word | Alt+B (or Esc then B) |
Moves the cursor backward one full word. |
2. Editing, Cut, Copy, and Paste
In shell terminology, the cut buffer is called the "kill ring."
| Action | Control Key | Alt / Meta Key | Description |
|---|---|---|---|
| Delete Character | Ctrl+D |
Deletes the character under the cursor. | |
| Delete Backwards | Backspace |
Deletes the character behind the cursor. | |
| Cut to Start | Ctrl+U |
Cuts (kills) everything from the cursor position to the beginning of the line. | |
| Cut to End | Ctrl+K |
Cuts (kills) everything from the cursor position to the end of the line. | |
| Cut Word | Alt+D |
Cuts (kills) the word from the cursor to its end. | |
| Paste | Ctrl+Y |
Pastes (yanks) the most recently cut text from the kill ring. | |
| Swap Characters | Ctrl+T |
Transposes (swaps) the character before the cursor with the character under the cursor. |
3. History and Recall (The "Find" Function)
| Action | Control Key | Alt / Meta Key | Description |
|---|---|---|---|
| Reverse Search | Ctrl+R |
Enters Reverse Incremental Search. Start typing, and it finds the most recent history match. Press Ctrl+R repeatedly to cycle through older matches. |
|
| Recall Last Arg | Alt+. (Alt + period) |
Cycles through the last argument of your previous commands. Extremely useful! | |
| Cancel Search | Ctrl+G |
Exits search mode and restores the original line. |
4. General Shell Commands
| Action | Control Key | Description |
|---|---|---|
| Send Interrupt | Ctrl+C |
Terminates the foreground process immediately (like stopping a long-running command). |
| Send Stop | Ctrl+Z |
Suspends the foreground process (sends it to the background). Use fg to bring it back. |
| Clear Screen | Ctrl+L |
Clears the entire terminal screen (same as typing clear). |
Regarding Nano vs. Bash/Zsh Bindings
The list you provided:
^G Help,^O Write Out,^F Where Is,^K Cut, etc.
...is the menu you see at the bottom of the nano editor. In nano, ^K (Ctrl+K) cuts a line, and ^U (Ctrl+U) pastes.
In the Bash/Zsh shell, the bindings are different: Ctrl+K cuts to the end of the line, and Ctrl+Y pastes.
Now that your nano search works and you are comfortable with Zsh, are there any other shell features you'd like to customize or learn about?
💡 Two Zsh Power-User Features
1. Autocd (Automatic Directory Change)
In Bash, to move into a directory, you must type cd first:
Bash
$ cd projects/my-app
In Zsh, if the command you type is a valid directory name, Zsh assumes you want to change to it. This saves countless keystrokes every day.
-
What you type in Zsh:
Bash
$ projects/my-app(And Zsh automatically runs
cd projects/my-app) -
How to enable it: This is typically enabled by default in Oh My Zsh. If it isn't, add this line to your
~/.zshrc:Bash
setopt autocd
2. Directory Stack Navigation (d command)
The directory stack is Zsh's memory of the places you've been. Instead of typing long relative paths (cd ../../...), you can jump directly back to any recently visited directory by number or name.
-
Type
dand press Enter: Zsh shows you a numbered list of your 10 most recent directories.$ d 0 ~ 1 ~/projects/cool-app 2 ~/Downloads 3 ~/etc/nginx -
Jump to a directory: To go back to
/etc/nginx(number 3), just type the number preceded by a tilde:Bash
$ ~3This immediately jumps you back. You can also type
cd -3.
That's great! autocd and the d directory stack are indeed massive time savers.
Now that you're digging into the core customization, let's explore more Zsh power features and tackle that color issue.
⚙️ Essential setopt Commands for Zsh
setopt is how you toggle most of Zsh's unique behaviors. Here are some of the most popular and powerful options to include near the top of your ~/.zshrc file:
| Command | Category | Description |
|---|---|---|
setopt menu_complete |
Completion | Press Tab once and it cycles through completion options (like hitting Tab repeatedly in Bash, but smoother). |
setopt auto_list |
Completion | If there are multiple completion options, it displays the list immediately instead of waiting for a second Tab. |
setopt correct |
Typing | If you type a command slightly wrong (e.g., git sttaus), Zsh will ask: zsh: correct 'sttaus' to 'status'? [ynai] |
setopt no_case_glob |
Files | Makes file and directory matching case-insensitive. ls *.jpg will match file.JPG. |
setopt extended_glob |
Files | Enables advanced globbing (wildcard matching), allowing you to exclude files or use logical operators. Essential for advanced scripting. |
setopt hist_ignore_dups |
History | Prevents identical consecutive commands from being saved in your history file. Keeps your history cleaner. |
setopt share_history |
History | Ensures that history is synced between all open Zsh windows immediately. |
Example of how to add these to ~/.zshrc:
Bash
# Add this block to your ~/.zshrc file
setopt autocd
setopt menu_complete
setopt auto_list
setopt correct
setopt hist_ignore_dups
setopt share_history
🎨 Fixing Colors for Typer/Rich CLI Tools
You've hit a common problem: your Zsh prompt (from Oh My Zsh) looks great, but modern Python tools like those built with Typer or Rich fall back to minimal colors, often because they can't detect true color support.
This is nearly always caused by the $TERM environment variable being set incorrectly. Modern terminals (and WSL 2) support 256 colors or even True Color (16 million colors), but if $TERM is set to the basic xterm, the application limits itself.
The Fix: Update $TERM
You need to force Zsh to tell applications that your terminal supports 256 colors.
-
Open your
~/.zshrcfile:Bash
nano ~/.zshrc -
Add this line near the top:
Bash
# Ensure terminal reports 256-color support for modern CLIs (Typer, Rich, etc.) export TERM="xterm-256color" -
Save and Reload:
Save the file (Ctrl+O, Ctrl+X) and reload your shell:
Bash
source ~/.zshrc
After running this, applications built with Rich and Typer should immediately detect the wider color pallet and display their intended output colors and formatting.
Next Step
Try adding a few of those setopt commands and the export TERM line to your ~/.zshrc! Once you've done that, let me know if those bright Typer/Rich colors start showing up.