terminal-craft / cheatsheets / shell tmux → nvim →

Shell

History, aliases, functions, PATH, and config load order — zsh-flavored.

History

↑ / ↓
step through history one command at a time
Ctrl-R + type
reverse incremental search (live substring match, most recent first)
Ctrl-R (repeat)
cycle to the next older match for the same search
Enter
run the found command as-is
any arrow key / typing
drop out of search mode, edit the found command first

Aliases

Pure text substitution — the shell rewrites the typed word before running anything. Only expands at the START of a command (or after ;/&&/|), never mid-line as an argument.

alias gs='git status'
define — gs now expands to git status
alias
list all currently defined aliases
unalias gs
remove one

Functions

Real shell logic — takes arguments ($1, $2, ...), can branch, loop, chain multiple commands. Use when an alias's dumb text-substitution isn't enough.

mkcd() {
  mkdir "$1"
  cd "$1"
}

PATH

echo $PATH
print the colon-separated list of directories the shell searches for commands, in order
which <command>
show which directory's copy actually runs
type <command>
like which, but also reports if it's an alias/function instead of a file on disk
First match wins — if two programs share a name and both directories are on PATH, whichever directory comes FIRST wins, silently. No error, no warning.

Config load order

source ~/.zshrc
reload the CURRENT shell in place (keeps your directory/session)
new terminal
starts a fresh shell that reads the file from scratch
.zshrc (or .bashrc) is read ONCE, at shell startup — not watched, not re-read automatically as you edit it.

Job control

command &
run a command in the background, get the prompt back immediately
Ctrl-Z
suspend the current foreground job
fg
resume the most recently suspended/backgrounded job in the foreground
bg
resume the most recently suspended job, but in the background
jobs
list all background/suspended jobs for this shell session

Modern CLI tools

The pattern across all of these: they add context (git state, ignore rules, usage history, data structure) that the classic Unix tool they replace predates and structurally cannot see.

eza -la --git
like ls -la, but git-aware — queries git per-file, shows status inline
rg <pattern>
like grep -r, but automatically respects .gitignore
fd <pattern>
like find, but gitignore-aware and simpler syntax
bat <file>
like cat, but with syntax highlighting and git-diff margin markers
z <fragment>
like cd, but ranks past directories by frecency and fuzzy-jumps
jq '.path.to.field'
parses real JSON structure instead of matching text — survives minified JSON

Mac-to-Mac migration

Three files, three sources of truth — full procedure in MIGRATION.md.

brew bundle dump --force
write every formula/cask/tap/vscode-extension/npm-global to a Brewfile — real reinstall directives, not just names
brew bundle install --file=Brewfile
replay a Brewfile on a new machine
mas list
list installed Mac App Store apps — invisible to Homebrew, different distribution channel
mas install <app-id>
reinstall by numeric App Store ID — the name alone doesn't work
APPS.md — plain checklist for anything with NO package-manager path at all. Kept honestly incomplete, filled in as gaps are actually noticed, not backfilled speculatively.