Skip to content
Hands-on IT IT Drills

Appendix A: Cheat Sheet

All keys and commands from Day 0 to 15 at a glance. State: lab configuration at the end of the book. Tested on macOS 15.6.1 with zsh 5.9, tmux 3.8, fzf 0.74, atuin 18.23, Neovim 0.12, Git 2.56, lazygit 0.66 and chezmoi 2.73. ⌃a | means: first ⌃a, release, then |.

Who listens to which key?

Layer Keys Example
Terminal app ⌘ ⌘D split, ⌘T tab
zsh (ZLE) ⌃ and ⌥ ⌃A start of line, ⌥B word back
tmux prefix ⌃a, then key ⌃a | split
Neovim modes, leader = Space ciw, ␣ff

Bound in the lab: ⌃R fzf history, ⌥R atuin, ↑ prefix search, ⌃T fzf files, ⌥C fzf cd. This overrides ⌃T (transpose characters) and ⌥C (capitalize) from Day 3.

Terminal app: iTerm2 and Ghostty

Key Effect Day
⌘T / ⌘N / ⌘W open tab / window / close 0, 1
⌘1 … ⌘9, ⌘⇧[ / ⌘⇧] tab directly / in order 1
⌘D / ⌘⇧D split right / down 1
⌘⌥←→↑↓, ⌘] / ⌘[ switch split 1
⌘⇧⏎ maximize split and back 1
⌘⌥I input to all splits (iTerm2) 1
⌘O open profile (iTerm2) 1
⌘⇧↑ / ⌘⇧↓ previous / next prompt mark 1
⌘⇧A select output of the last command 1
⌘F / ⌘K search / clear scrollback 0, 1
⌘, Settings 1
⌘⇧, reload configuration (Ghostty) 1
Hotkey (⌥␣ or ⌃^) hotkey window / Quick Terminal 1
# What does a key really send? (⌥B must show ^[b, quit with ⌃C)
cat -v
# Check truecolor and app
echo "$TERM_PROGRAM $TERM $COLORTERM"
# Ghostty: effective configuration and default keys
ghostty +show-config | grep -E 'font-family|option-as-alt'
ghostty +list-keybinds --default | grep new_split
# Clipboard via OSC 52 (over SSH and tmux too)
printf '\e]52;c;%s\a' "$(printf 'via OSC 52' | base64)"

zsh: editing the line

Key Effect Day
⌃A / ⌃E start of line / end of line 3
⌥B / ⌥F, ⌥← / ⌥→ word back / forward 3
⌃B / ⌃F character back / forward 3
⌃W, ⌥⌫ delete word to the left (stops at / . -) 3
⌥D delete word to the right 3
⌃U / ⌃K delete everything left / right of the cursor 3
⌃Y / ⌥Y paste / older kill ring entries 3
⌃_, ⌃X⌃U undo 3
⌥T transpose words 3
⌥U / ⌥L word UPPER / lower 3
⌥Q park the line, back after ⏎ 3
⌥. last word of the previous command (repeatedly: further back) 3
⌃X⌃E edit the line in $EDITOR 3, 11
⌃X a expand alias in the line 5
⌥H man page for the command, line stays –
⌃V + key insert key raw 1, 3
⌃C / ⌃L / ⌃D discard line / clear screen / exit shell 0, 3

zsh: expansion, globs, completion

Input Effect Day
!!, !$, !^, !*, !-2, !git history expansion 3
^alt^neu last command with substitution 3
!!:s/a/b/:s/c/d/ several substitutions in a row 15
datei{,.bak}, {01..10..3} brace expansion 3
**/*.go, config/^*.json recursive, negation 3
*(.), *(/), *(.om[1,2]), *(.Lk+10) qualifiers: file, folder, newest, size 3
*(N), *(:t), *(:r) no error, name only, without extension 2, 3
⇥ / ⇧⇥ / ⌃G complete, menu forward / back / cancel 2
⌃Xh which completion applies here? 2
cd -⇥, cd -2, dirs -v directory stack 2
.., projekt cd without cd (AUTO_CD) 2
# Startup files and startup time
zsh -o sourcetrace -l -i -c exit
hyperfine -N -w 3 'zsh -i -c exit'
# Options, bindings, origin
setopt; bindkey '^R'; whence -v git; type gs
# Mass rename with dry run
autoload -Uz zmv; zmv -n '(**/)(*).yaml' '$1$2.yml'
# Reload the shell (alias from Day 5)
reload

History: ↑, ⌃R, atuin

Key Effect Day
↑ / ↓ history, filtered by what’s typed 4
⌃R fzf search in the history 4, 7
⌃R in fzf sorting relevance / time 4
? in fzf history show long commands wrapped 7
⌥R atuin search 4
⌃R in atuin filter: global, host, session, folder 4
⇥ in atuin take the line and edit it 4
␣befehl not into the history (HIST_IGNORE_SPACE) 4
# Built-in tools (available on every server)
history -i -10              # with date and time
fc -l -m 'git*' 1           # all git commands
r wc                        # repeat the last command with "wc"
fc                          # last command in the editor, run after :wq
# atuin: folder, exit code, time, statistics
atuin search --cwd . --exclude-exit 0 --format "{exit}  {command}"
atuin search --after yesterday --exit 0 kubectl
atuin stats
HISTFILE=$HISTFILE atuin import zsh

fzf

Key Effect Day
⌃T insert file(s) into the line 7
⌥C (or Esc c) change into a subfolder 7
**⇥ fzf for the current argument (cd, kill, ssh, export) 7
⌃J / ⌃K, ↓ / ↑ move in the list 4, 7
⇥ / ⇧⇥ mark / remove mark 7
⌃/ preview on/off (lab config) 7
Esc, ⌃C cancel (exit code 130) 7
Pattern Meaning Day
cmdgo fuzzy, letters in order 7
'cart exact 7
^config / .yaml$ starts with / ends with 7
!deploy doesn’t contain 7
a b both (AND) 7
fd -t f | fzf                       # selection on stdout
bat "$(fd -e yaml | fzf)"           # pass the selection on
fzf --filter "^int" < liste.txt     # test search syntax without the UI
# own pickers from fzf.zsh (Day 7)
fbr                                 # pick a Git branch and switch
fkill                               # pick processes (⇥) and kill them
fkctx                               # pick a kubeconfig context
frg TODO                            # pick an rg match, editor at the line
zi                                  # zoxide with fzf (Day 6)

tmux: sessions, windows, panes

The prefix is ⌃a. Lab invocation: tl (= tmux -L lab -f ~/term-lab/tmux.conf).

Key Effect Day
⌃a d leave the session, keeps running 8
⌃a s / ⌃a w sessions / windows as a tree 8
⌃a ( / ⌃a ) previous / next session 8
⌃a $ / ⌃a , rename session / window 8
⌃a c new window in the current path 8
⌃a 1 … ⌃a 9, ⌃a n window n, next window 8
⌃a ⌃h / ⌃a ⌃l previous / next window (repeatable) 8
⌃a ⇥ last used window 8
⌃a & close window (with confirmation) 8
⌃a | / ⌃a - split vertically / horizontally 8
⌃a h j k l switch pane 8
⌃a H J K L resize pane (repeatable) 8
⌃a z / ⌃a q zoom pane / show numbers 8
⌃a x / ⌃a ! close pane / turn into window 8
⌃a ␣, ⌃a ⌥1 … ⌥5 next layout / directly 9
⌃a = grid (tiled) 9
⌃a S synchronize-panes on/off 9
⌃a f / ⌃a g / ⌃a t popup: project picker / lazygit / shell 9
⌃a ⌃s / ⌃a ⌃r save / restore sessions 9
⌃a r / ⌃a m reload config / toggle mouse 8
⌃a ⌃a pass ⌃a through (shell, inner tmux) 8, 9
F12 mute/unmute the outer tmux 9
⌃a ? all key bindings 8

tmux: copy mode (vi)

Key Effect Day
⌃a ⏎ (or ⌃a [) start copy mode 8
/ / ?, n / N search forward / back, next match 8
v / V / ⌃v select character / line / block 8
y copy, to macOS too (pbcopy) 8
w b 0 $ g G word, line, start, end of the history 8
⌃u / ⌃d half page up / down 8
q, Esc exit copy mode 8
⌃a P paste tmux buffer 8
tl new -A -s lab                          # attach or create
tl ls; tl kill-session -t ops; tl kill-server
tp ~/term-lab/projekt                     # project session (Day 9)
tl new -s shop -n main \; split-window -h \; split-window -v \; \
  select-layout main-vertical             # three panes, one command (Day 15)
tmux send-keys -t '{right}' 'git s' Enter # type into a pane
tmux capture-pane -p -t '{right}'         # read pane contents
tmux display -p '#{session_name}:#{window_index}.#{pane_index}'
tmux list-keys -T prefix | rg split       # check bindings
ssh -t host 'tmux new -A -s main'         # tmux on the server

Neovim

Key Effect Day
w b e, W B word forward / back / end, WORD up to whitespace 11
0 ^ $ start of line, first character, end of line 11
gg G 5G, { } start, end, line 5, paragraph 11
f( t, ; , jump within the line, repeat 11
% matching bracket 11
/muster n N, * # search, word under the cursor 11
d c y + motion delete, change, yank (d3w, ct,) 11
ciw ci" di( yi{ dap text objects: inner / around 11
. repeat the last change 11
* N cgn … . replace match by match 11
qa … q, @a, @@ record, play back, repeat a macro 11
u / ⌃R undo / redo 11
V … g⌃A increment numbers progressively 11
⌃O / ⌃I jump list back / forward 11
⌃H ⌃J ⌃K ⌃L switch windows (lab mappings) 11
␣ff / ␣fg / ␣fb find file / grep / buffer 11
␣e / ␣w / ␣q netrw / save / close window 11
]c / [c next / previous diff hunk 11
Command Effect Day
:%s/\<port\>/nr/gc replace with word boundaries and confirmation 11
:silent grep! TODO, :copen rg matches into the quickfix list 11
:cdo + command command on every quickfix match (example below) 11
:g/print/d, :g!/def/d delete lines with / without pattern 11
:vs datei, :ls, :b# split, buffer list, previous buffer 11
:wq, :qa, :cq save+quit, close all, exit with error 3, 11
:%s/\<port\>\ze[,)]/port_nr/gc     variables only, with confirmation
:cdo s/TODO/FIXME/ | update        in all quickfix matches, save
:0put ='hosts:'                    insert a line above the first
nv +16 internal/cart/cart.go          # straight to line 16
nv -q <(rg --vimgrep TODO)            # rg matches as quickfix
nv -d a.yaml b.yaml                   # diff mode
git log --oneline | nv -              # stdin as a buffer
nvim --headless -u ~/term-lab/config/nvim/init.lua +q   # test the config
sudoedit /etc/hosts                   # editor as you, write as root

Git aliases (lab gitconfig, Day 10)

Alias Command What for
git s status -sb short status
git co / git cob switch / switch -c switch / create branch
git co - switch - back, like cd -
git unstage restore --staged take out of the index
git last log -1 --stat last commit with files
git lg / git ll graph with author / log --oneline -15 history
git amend commit --amend --no-edit amend the last commit
git fixup <rev> commit --fixup fixup for an old commit
git ri <basis> rebase -i --autosquash fold in fixups
git wip commit everything as wip park quickly
git undo reset --soft HEAD~1 undo commit, changes stay
git br / git wt branch -vv / worktree list overview
git aliases list all aliases memory aid
git add -p                                  # y n s e: choose hunks
git fixup ":/feat: sub"                     # target via commit message
GIT_SEQUENCE_EDITOR=: git ri --no-update-refs HEAD~3
git commit --fixup=reword:":/feat: div"     # change only the message
git worktree add ../hotfix -b hotfix/x      # second checkout
git bisect start HEAD main && git bisect run ./test.sh && git bisect reset
git reflog                                  # find any old state again
git push --force-with-lease                 # never blind --force
gh pr create --fill --draft; gh pr checks --watch; gh run view --log-failed

lazygit

Key Effect Panel
1 … 5, ⇥ panel: Status, Files, Branches, Commits, Stash all
␣ stage / check out Files, Branches
a stage / unstage all Files
⏎ into the file, then stage lines individually Files
c / A commit / amend last commit Files
d discard change / drop commit Files, Commits
P / p push / pull all
F fixup commit for the selected commit Commits
S fold in all fixups above Commits
s / f / r squash / mark as fixup / reword Commits
⌃J / ⌃K move commit down / up Commits
n / M / r new branch / merge / rebase Branches
z / Z undo / redo all
/, ?, q search, key help, quit all

Modern CLI tools (Day 6)

rg TODO; rg -t go -w port; rg -l TODO; rg -C1 TODO; rg -uu -c ERROR
fd -e go; fd -t d; fd -H gitignore; fd -u -e log; fd -e go -x wc -l
bat -r 10:14 main.go; bat -A datei; bat -l yaml
eza -l --git; eza --tree --level=2 --git-ignore      # aliases ll, la, lt
z cart; z conf zsh; z -; zi; zoxide query -ls
jq -r '.service, .replicas' config/app.json
jq -r 'select(.level == "ERROR") | .req' logs/app.jsonl | paste -sd, -
jq -sc 'map(select(.level == "ERROR")) | length' logs/app.jsonl
yq '.spec.template.spec.containers[0].image' deploy/k8s/deployment.yaml
yq -o json '.features' config/app.yaml; yq -i '.spec.replicas = 5' datei.yaml
delta a b; git diff main feature/rabatt | delta --side-by-side
btop; tldr tar; http :8765/config/app.json; http POST :8080/api/cart sku=A1 qty:=2
Key Effect Tool
n / N next / previous file delta
f / k / e / q filter / kill process / tree / quit btop
q, /, G quit, search, to the end less, man

Aliases and lab functions

Name Effect Day
.. ... md h path up, two up, mkdir -p, history, PATH line by line 5
G L H C J NE global aliases: grep, less, head, wc, jq, 2>/dev/null 5
mkcd up bak gcd create+change into, n levels up, backup, repo root 5
extract port please unpack, port listeners, last command with sudo 5
loglevels, gmerged script in bin, autoload function 5
tl, tp lab tmux, project session 8, 9
nv Neovim with lab config 11
lssh ssh -F ~/term-lab/ssh/config 12, 15
cz, czneu chezmoi in the lab, new Mac in the lab 13, 15
k kgp kgpa kd kl kx kn kubectl short forms 14
wk, wkstand stopwatch, points 15

SSH (Day 12)

Key / command Effect Day
⏎ ~ . terminate a hung session 12
⏎ ~ # / ⏎ ~ ? forwardings / all escapes 12
ssh -G host effective configuration without connecting 12
ssh -O check / -O exit check / exit the master 12
ssh -J bastion app-web01                     # ad hoc via the bastion
ssh -f -N -L 19080:127.0.0.1:18080 bastion   # tunnel in the background
ssh -O forward -L 19081:127.0.0.1:18080 bastion   # attach tunnel to master
scp -O -F ~/term-lab/ssh/config lab-app:term-lab/projekt/logs/app.log .
ssh-add -t 1h ~/.ssh/id_ed25519; ssh-add -l
ssh-keygen -t ed25519 -C "du@mac"
Host app-*                    # specific at the top, "Host *" at the bottom
  HostName %h.internal.example.com
  ProxyJump bastion
Host *
  ControlMaster auto
  ControlPath ~/.ssh/cm-%C
  ControlPersist 10m
  AddKeysToAgent yes
  UseKeychain yes

macOS commands (Day 12, 13)

open .; open -R datei; open -a TextEdit datei
cmd | pbcopy; pbpaste | wc -l
mdfind -onlyin ~/term-lab 'kMDItemFSName == "*.go"'; mdls -name kMDItemKind datei
caffeinate -i make test; caffeinate -d -t 3600 &
defaults read com.apple.dock autohide; defaults read-type -g AppleLocale
defaults export com.apple.dock dock-backup.plist   # before every write!
networkQuality -M 8; sw_vers --productVersion; sysctl -n machdep.cpu.brand_string
say -v Anna "Build fertig"; osascript -e 'return (1 + 1) as text'
security find-generic-password -s github-cli -w   # token from the keychain
plutil -lint agent.plist; launchctl print gui/$(id -u)/de.term-lab.heartbeat

Projects and Kubernetes (Day 14)

direnv allow; direnv status                    # approve / check .envrc
mise use [email protected] [email protected]; mise current     # versions per project
make; make test vet lint                       # make help is the "help" target
just --list; just report logs/app.log
kubectl config get-contexts; kubectx kunde-dev; kubectx -; kubectx -c
kubectl config set-context --current --namespace=shop
kubens shop                                    # needs a reachable cluster
k9s --context kunde-prod --readonly
shellcheck scripts/*.sh
fd -e go | entr -c go test ./...; watch -n 2 'kubectl get pods'
hyperfine -N --warmup 3 'zsh -i -c exit'
Key Effect Tool
:pods, :deploy, :ctx pick resource / context k9s
/ filter k9s
l / d / s logs / describe / shell k9s
⌃D delete (blocked with --readonly) k9s
#!/usr/bin/env bash
set -euo pipefail                             # header of every script
IFS=$'\n\t'
trap 'echo "✘ Zeile $LINENO: $BASH_COMMAND" >&2' ERR
tmp="$(mktemp)"; trap 'rm -f -- "$tmp"' EXIT

Dotfiles and a new Mac (Day 13)

chezmoi init --apply https://github.com/DEIN-USER/dotfiles.git   # new Mac
chezmoi add ~/.zshrc; chezmoi edit ~/.zshrc; chezmoi diff; chezmoi apply -v
chezmoi status; chezmoi re-add; chezmoi managed; chezmoi data
chezmoi chattr +template ~/.zshrc; chezmoi execute-template < datei.tmpl
chezmoi cd                                     # shell in the source directory
chezmoi git -- log --oneline
brew bundle check --no-upgrade --file=Brewfile
brew bundle dump --file=Brewfile.ist; brew bundle cleanup --file=Brewfile
./bootstrap.sh; ./bootstrap.sh --apply         # dry run, then for real
Prefix / file Meaning Day
dot_ / private_ / executable_ . / permissions 0600 / executable 13
.tmpl template with {{ .hosttype }}, onepasswordRead, keyring 13
.chezmoiignore / .chezmoiremove don’t manage / actively delete 13
run_onchange_ script runs when its content changes 13