Small programming tricks

signa11 470 points 206 comments September 16, 2026
will-keleher.com · View on Hacker News

Discussion Highlights (20 comments)

behnamoh

This reminded me to ask: To what extent are people still coding by hand these days? In my profession (academia), literally no one codes anymore. On one hand, it sucks because the joy and fun of programming has been replaced by constant agent orchestration tasks, but on the other hand, it's hard to go back to the way things were before because the productivity gain is so good. I remember learning a lot of these programming tricks over the years. They would give me happiness: learning something new about nvim, or some new shortcut in the Fish shell, or a new Vim macro, or the difference between 1 bracket or 2 brackets in Bash scripts, etc. But now it seems like all of them are irrelevant, and I wanted to see how others think about the situation.

VCFundedGenYer

I would probably retitle this less as "programming tricks" rather instead make it "bash/zsh CLI tricks" as this only really tangentially refers to programming.

Natashash23

nice content

winternewt

Only a few of these are actual programming tricks. The problem with sharing them is that they'll typically seem obvious to you, since you know them. It's difficult to know what is actually unknown to other people, and if you share stuff everybody knows you risk coming off as arrogant. Here's one that I think more people should know: avoid branches. If I can do the same thing without an if statement and even a logical expression, the code typically both becomes easier to understand for people and easier to run for the CPU.

overflowy

If you want to level up your Zsh history experience, I built zhist[1] specifically for that. It uses fzf underneath, but provides considerably more context than simply using fzf. There's a demo video in the README. [1] https://github.com/overflowy/zhist

jawns

I would love for someone to package up some kind of script or AI skill that evaluates your current terminal config/set-up and applies all of these tips and tricks. For instance, it might detect that you currently use ag, install ripgrep, and offer a short tutorial on how users accustomed to ag should use it. Or it might look at the history of git commands you've run and offer tips on efficiency improvements.

NegativeLatency

> At a previous company, I shared a trick on slack every day with the engineering team, both technical and company-specific, and folks found them pretty useful. I would find that annoying, however to not be seen as a jerk I wouldn't say anything.

adzm

My favorite is generating a sequential resultset of the numbers 1-4096 in SQL Server with this simple query: ;with [[[]][[[](_)as(select 1 union select 0),[[]][]][](_)as(select 1 from [[[]][[[] []]]][]]],[[[]][[[] _),[]][]][[](_)as(select 1 from [[]][]][] []]]][]]],[[]][]][] _),[[[[[]][](_)as(select 1 from []][]][[] []]]][]]],[]][]][[] _),[[[]][]]](_)as(select 1 from [[[[[]][] []]]][]]],[[[[[]][] _)select _ from(select row_number()over (order by _)from [[[]][]]])[[[]][[[](_); /s

williamcotton

Additional tip: In the macOS terminal you can... Ctrl + Option + - ...and it'll undo your typing. Dunno about other OS keys!

AJRF

I started writing little "that's useful to remember" tips on my website. Bit more durable than shell history, and you can share them! https://adamfallon.com/til.html

aDyslecticCrow

Wrote "script" by accident once in my terminal. Turns out the unfortunate naming of that gnu tool from unix days makes it rather unknown. Record a debugging terminal session including output to a file. Its pretty great.

elendilm

These bash commands along with similiar others makes a developer so productive. For me, I personally use nothing fancy other than normal KDE Kate for backend development. Function and variable names are chosen after putting a lot of thought into it which also includes being amenable to grep and sed.

ahmedhossamdev

+1 for git log -S. Two I use daily: rg --hidden -g '!*.lock' to skip noise, and python3 -m json.tool to pretty-print API responses.

cachvico

I find myself using ctrl-r less and less as I make sure that anything of value that I work out goes into a Makefile or the app tooling, for me this is the basis of the dev-ops approach to work (make sure everything is scripted, not worked out on the fly).

monideas

Almost all of these are irrelevant in the age of AI, except for the logarithm thing

wiredfool

You might not need find due to advanced globs, but it's too easy to run into expansion limits when you match hundreds or thousands of files, so you're back to find for that.

okinternets

Another one I use often is <command returning output > | pbcopy on macOS. Pipes the the result directly into your clipboard

IsTom

`find` does a lot more things than that.

kccqzy

A lot more tricks can be learned from just watching AI work. Instead of allowing AI to work autonomously, go back to the old days where you manually approve every command the AI runs. Just recently while doing performance optimization work, I found Opus using the `perf` command in ways I didn’t know possible. Just give AI a real task and carefully read what commands are used by the AI to solve the problem; most likely the AI uses a trick or two that you didn’t know existed.

jonstaab

I miss posts like this

Semantic search powered by Rivestack pgvector
6,833 stories · 62,541 chunks indexed