Sneaky CLI Tricks You Probably Missed
Here's a fast burst of command-line goodness to shake up your dev life.
1. Instantly Dig Up Old Commands With history, grep, and fzf
Ever find yourself blanking on that Docker command you used last week? Same. Just run:
history | grep docker | fzf
Scroll, pick the one you need, hit Enter, and boom—it's back at your prompt.
Feels like magic, but nope, that's just fzf working for you.
2. Track Down When Code Snippets Showed Up in Git
Stop scrolling forever trying to figure out when someone slipped in that random
line of code. You can search your git history by file contents with the -S
flag:
git log -S "resizeObserver" --oneline -- src/components/header.tsx
Now you know exactly when that string landed. No more endless digging.
3. Pretty-Print JSON—No Extra Installs Needed
Sick of reaching for jq every time you want to read some messy JSON? Turns out
python3 can handle it out of the box:
cat response.json | python3 -m json.tool | less
No extra installs, no hassle.
4. Dead-Simple Port Forwarding With SSH
Want to show off your local site on port 3000? Don't bother with ngrok and
logins. Just run:
ssh -R 80:localhost:3000 ssh.localhost.run
You'll get a public URL right away. Drop it in Slack, then sit back and watch the surprised reactions roll in.
5. Time Anything—No Stopwatch, No Fuss
Ever wonder why your linter takes so long? Find out for real:
time (npm run lint > /dev/null)
Tip: stick this in a pre-push hook so you can stop slow commands before they wreck your workflow.
There you go—CLI tricks for days, no top hat required.