Skip to content

Tricks & Shortcuts

ShortcutAction
Ctrl + CCancel current command
Ctrl + LClear screen (same as clear)
Ctrl + AMove cursor to start of line
Ctrl + EMove cursor to end of line
Opt + Left/RightMove cursor word by word
TabAuto-complete file/folder names
Up ArrowPrevious command
Ctrl + RSearch command history

Helpful Tricks

Command History

  • Press Up Arrow to cycle through previous commands
  • Type history to see all recent commands
  • Press Ctrl + R and start typing to search history

Chaining Commands

bash
# Run two commands in sequence
mkdir my-project && cd my-project

# Run second command only if first succeeds
brew update && brew upgrade

Piping Output

Send the output of one command into another:

bash
# Count files in a directory
ls | wc -l

# Search for a word in command output
history | grep "brew"

Aliases

Create shortcuts for long commands. Add to ~/.zshrc:

bash
# Open .zshrc to edit
nano ~/.zshrc

# Add aliases like these:
alias ll="ls -la"
alias gs="git status"
alias brewup="brew update && brew upgrade && brew cleanup"

# Save (Ctrl+O, Enter) and exit (Ctrl+X)
# Reload:
source ~/.zshrc