Shell Tricks That Actually Make Life Easier (And Save Your Sanity)
Source
1 min read
Summary
A well-organized reference of shell keyboard shortcuts and CLI tricks split into two tiers: universal POSIX-compatible commands and Bash/Zsh-specific enhancements. Covers line editing, history search, brace expansion, process substitution, backgrounding, and scripting safety flags.
Key Insight
- The POSIX-portable tier (CTRL+W, CTRL+U/K/Y, CTRL+A/E, ALT+B/F,
cd -,pushd/popd,$_,> file.txttruncation) works on minimal systems, SSH into embedded devices, and containers - worth committing to muscle memory first since they transfer everywhere CTRL+Ucuts the line to a kill ring, andCTRL+Yyanks it back - this is a clipboard for your terminal that most people never discover, letting you “park” a half-written command while you run something elseCTRL+X CTRL+E(Bash) orfc(portable) opens the current command in$EDITOR- critical for editing complex multi-pipe commands that outgrow the single-line promptset -euo pipefailis the recommended scripting safety net, but the author correctly warns thatset -ehas non-obvious edge cases inside conditionals and pipelines - false confidence is worse than no safety netdisownafterCTRL+Z+bglets you detach a running process from the shell after the fact - the rescue move when you forgottmux/screen- Brace expansion (
cp file{,.bak},mv file.{txt,md},mkdir -p project/{src,tests,docs}) eliminates repetitive path typing and is underused even by experienced users