Shell Tricks That Actually Make Life Easier (And Save Your Sanity)

Source 1 min read
shellbashzshterminalclikeyboard-shortcutsposixdevops

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.txt truncation) works on minimal systems, SSH into embedded devices, and containers - worth committing to muscle memory first since they transfer everywhere
  • CTRL+U cuts the line to a kill ring, and CTRL+Y yanks 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 else
  • CTRL+X CTRL+E (Bash) or fc (portable) opens the current command in $EDITOR - critical for editing complex multi-pipe commands that outgrow the single-line prompt
  • set -euo pipefail is the recommended scripting safety net, but the author correctly warns that set -e has non-obvious edge cases inside conditionals and pipelines - false confidence is worse than no safety net
  • disown after CTRL+Z + bg lets you detach a running process from the shell after the fact - the rescue move when you forgot tmux/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