Shell Tricks That Make Life Easier (and Save Your Sanity)

Shell editing modes & readline behavior

  • Many comments clarify that several “shell tricks” are actually readline features and thus widely available.
  • There’s debate over emacs-style vs vi-style editing: POSIX mandates vi-mode (set -o vi), but many people still prefer emacs bindings.
  • Some praise vi-mode (and its presence in many tools), others dislike switching modes across different machines and prefer only occasional editor handoff (Ctrl-x Ctrl-e / Alt-e).
  • Configuring readline/.inputrc to show vi mode indicators and customize word boundaries ($WORDCHARS) is highlighted as valuable.

History search, annotation, and tools

  • Heavy praise for Ctrl-r reverse search; tips include pressing it twice to reuse the last query and repeatedly cycling through matches.
  • Several users tag commands with inline comments and later retrieve them via Ctrl-r or history | grep '#'.
  • Tricks to temporarily “comment out” a long command: prepend #, run it to store in history, do other tasks, then recall and remove #.
  • Warnings and mitigations about sudo !!: risk of accidentally re-running unknown commands as root; alternatives include manual prefixing or custom bindings.
  • Use of leading spaces to keep commands out of history, and custom filters to exclude dangerous patterns (--force, etc.).
  • Third‑party history tools like fzf, mcfly, and atuin are recommended for faster, richer search; some like cross‑machine sync, others prefer history to remain machine‑specific but “eternal”.

Line editing shortcuts & ergonomics

  • Strong enthusiasm for Ctrl-u, Ctrl-k, Ctrl-w, Ctrl-y, Alt-., and undo (Ctrl-_), with emphasis on their ubiquity.
  • Some remap arrow keys or use history-search-on-prefix (up/down only cycle commands starting with current text), calling it “life-changing.”
  • Ctrl-z for fast suspend, then kill or fg, is called an “emergency exit,” with clarifications about signals.

Pipeline and scripting tricks

  • Creative scripts like # to “comment out” a pipeline stage (mycmd1 | \# mycmd2 | mycmd3) are praised as simple but powerful.
  • Other snippets: noglob wrappers, robust bash script headers (set -eEuo pipefail), and | sudo tee file for writing where redirection is disallowed.

Meta reactions & skepticism

  • Some feel the article’s tone is “LLM-ish” or mixed in quality but still learned new, genuinely useful tricks.
  • Others argue that relying on LLMs instead of learning CLI tools wastes time and money, while a minority see tools as purely instrumental and not worth deeper mastery.