GKRootWire
Cloud & Sysadmin Microsoft Confirms Preview Update Wipes Out Desktop SettingsAI Nvidia to Acquire Hugging Face for $12.9 BillionDev Tools A Deep Dive Into Intrusive Linked ListsGadgets DJI's Romo 2 Robovac Adds Local-Only Mode After Privacy ScareAI Nvidia Reportedly Moves to Acquire Hugging FaceAI Anthropic Launches Claude Tools for AI Shopping AgentsCloud & Sysadmin Microsoft Confirms Preview Update Wipes Out Desktop SettingsAI Nvidia to Acquire Hugging Face for $12.9 BillionDev Tools A Deep Dive Into Intrusive Linked ListsGadgets DJI's Romo 2 Robovac Adds Local-Only Mode After Privacy ScareAI Nvidia Reportedly Moves to Acquire Hugging FaceAI Anthropic Launches Claude Tools for AI Shopping Agents
Dev Tools

The Shell's '!' Isn't for Emphasis—It's a Shortcut You're Probably Underusing

A deep dive into bash and zsh's history expansion shows how the exclamation mark can save you from retyping long commands.

Most terminal users know '!!' repeats the last command, but a recent write-up argues that the exclamation mark's full history expansion powers go largely ignored. The shell's '!' operator isn't punctuation for shouting—it's a lazy shortcut for referencing previous commands without retyping them.

The article walks through lesser-known tricks: '!$' grabs the last argument of the previous command, '!^' grabs the first, '!*' grabs all arguments, and '!string' reruns the most recent command starting with that string. You can even combine these with substitution, like '!!:s/old/new/', to fix a typo in your last command without rewriting the whole line.

These features have existed in bash and zsh for decades, inherited from the original C shell, but they're easy to forget since most people rely on up-arrow and tab completion instead.

Why it matters: History expansion is one of those shell features that's invisible until you need it, and knowing it can shave real time off repetitive terminal work like rerunning a build with tweaked flags. It's also a good reminder that shells have deep, often underused feature sets worth revisiting periodically.

Sources: Hacker News