Essential keyboard shortcuts and productivity tips for Bash and Zsh terminal navigation, editing, and history
Cursor Navigation
Moving Around
Shortcut
Action
Ctrl + A
Move to beginning of line
Ctrl + E
Move to end of line
Ctrl + F
Move forward one character
Ctrl + B
Move backward one character
Alt + F
Move forward one word
Alt + B
Move backward one word
Ctrl + XX
Toggle between start of line and current position
Quick Tips
# Use arrow keys + Ctrl for word jumping
Ctrl + → (Right Arrow)# Move forward one word
Ctrl + ← (Left Arrow)# Move backward one word
Text Editing
Deleting Text
Shortcut
Action
Ctrl + D
Delete character under cursor
Ctrl + H
Delete character before cursor (backspace)
Ctrl + W
Delete word before cursor
Alt + D
Delete word after cursor
Ctrl + K
Delete from cursor to end of line
Ctrl + U
Delete from cursor to beginning of line
Cut, Copy, Paste
Shortcut
Action
Ctrl + Y
Paste (yank) last deleted text
Alt + Y
Cycle through kill ring (previous yanks)
Ctrl + K
Cut from cursor to end of line
Ctrl + U
Cut from cursor to start of line
Modifying Text
Shortcut
Action
Ctrl + T
Swap current character with previous
Alt + T
Swap current word with previous
Alt + U
Uppercase word from cursor
Alt + L
Lowercase word from cursor
Alt + C
Capitalize word from cursor
Ctrl + _
Undo last edit
Command History
Navigation
Shortcut
Action
↑ / Ctrl + P
Previous command
↓ / Ctrl + N
Next command
Ctrl + R
Reverse search history
Ctrl + S
Forward search history
Ctrl + G
Cancel history search
Alt + .
Insert last argument of previous command
History Expansion
# Execute last command!!# Execute command N in history!N
# Execute last command starting with 'git'!git
# Execute last command containing 'commit'!?commit?
# Use arguments from last commandecho hello world
echo!!:*# Uses "hello world"echo!!:1 # Uses "hello"echo!!:2 # Uses "world"echo!!:$ # Uses last argument "world"# Replace in last command
^old^new # Replace 'old' with 'new' and execute
# Repeat last command!!# Repeat with sudosudo!!# Change directory backcd -
# Refer to home directorycd ~
cd ~/projects
# Refer to previous directorycd ~-
# Quick directory changes (zsh)cd ... # Go up 2 directoriescd .... # Go up 3 directories# Directory stackpushd /path # Push directory to stackpopd# Pop and go to previousdirs-v# List directory stack# Auto cd (if enabled)
/path/to/dir # Same as: cd /path/to/dir
This website uses cookies and similar technologies to enhance your browsing experience, analyze traffic, and provide personalized content.
Learn more in our Privacy Policy.
Cookie Preferences
Customize your cookie preferences below. You can change these settings at any time by clicking the cookie preferences link in our footer.
Essential Cookies
Always Active
These cookies are necessary for the website to function properly. They enable core functionality such as navigation, security, and accessibility features.
Analytics Cookies
These cookies help us understand how visitors interact with our website by collecting anonymous information about page visits, time spent, and user behavior patterns.
Comments