Live data from Hacker News

Small programming tricks

will-keleher.com

191–200 of 205 posts

Re: Small programming tricks

#191
post #37

`find` does a lot more things than that.

Definitely. The whole Unix philosophy of each command doing one thing and being easily composable always seemed to break down in my mind when it came to find. find does a lot. similar to ripgrep, though, fd is a modern replacement that’s a bit friendlier to use.

find is absolute agony once you get a taste of fd.

Re: Small programming tricks

#192

> 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.

As long as they do that in separate channel and don't tag all, i'm fine with it.

Re: Small programming tricks

#194
post #190
post #117

Earlier quoted context omitted.

(hi! I work on atuin!) yes, it's improved a lot in the last couple of years! what in particular bothered you?

Not the parent commenter, but I also tried it a year or two ago and my recollection is that I had a similar experience. I have a really long history file that dates back like a decade and if remembering correctly I tried to import it, and it made using my shell very laggy so I ended up removing it. I'm not 100% positive that I'm remembering the exact way that I started experiencing the lag though, so if I have time t…

Ahh yes, we’ve done a lot of performance optimisation since then. We regularly test on >1m records and have no issues

Make sure you’re using the daemon (the install script will handle this) and you should be good to go

Very happy to help if you have any problems. Ellie at Atuin dot sh

Re: Small programming tricks

#195
post #77

The thing with a lot of these tricks is that you have to get into the habit of using them. I knew `Ctrl+r` for history since I learned about the command line. I even have a nice shell integration with fzf. But I still used the up/down arrow keys for years or scrolled up when I was looking for a previous command, because I never remembered the shortcut and just took the path of least resistance to find something. Usua…

Bonus: if you write all your tricks in a document, people will love your document. Whenever I offer a new student my CHEATSHEET.md file, their eyes absolutely light up.

Re: Small programming tricks

#196
post #194
post #190

Earlier quoted context omitted.

Not the parent commenter, but I also tried it a year or two ago and my recollection is that I had a similar experience. I have a really long history file that dates back like a decade and if remembering correctly I tried to import it, and it made using my shell very laggy so I ended up removing it. I'm not 100% positive that I'm remembering the exact way that I started experiencing the lag though, so if I have time t…

Ahh yes, we’ve done a lot of performance optimisation since then. We regularly test on >1m records and have no issues Make sure you’re using the daemon (the install script will handle this) and you should be good to go Very happy to help if you have any problems. Ellie at Atuin dot sh

Good to hear! Sounds like my history file might not even be that large compared to your tests now

Re: Small programming tricks

#197
post #143

Earlier quoted context omitted.

Another one, not quite as handy but still awesome: ctrl s / ctrl-q. This freezes/unfreezes the terminal output so you can read it, without interrupting your program. Useful for very fast walls of text.

It can’t always not interrupt your program. Think about it: after you press Control S to trigger XOFF, the fast output has to be buffered in memory. That memory is certainly not unlimited. There’s no way for the program to keep outputting text. Indeed some programs (including Claude Code, at least a while ago) really don’t like it when you press Control S and let the terminal be frozen for a very long time.

Interesting; I assumed the write to stdout would just hang for the writing program.

Re: Small programming tricks

#198
post #86
post #77

The thing with a lot of these tricks is that you have to get into the habit of using them. I knew `Ctrl+r` for history since I learned about the command line. I even have a nice shell integration with fzf. But I still used the up/down arrow keys for years or scrolled up when I was looking for a previous command, because I never remembered the shortcut and just took the path of least resistance to find something. Usua…

> But I still used the up/down arrow keys for years or scrolled up when I was looking for a previous command It's not even that bad of a habit with zsh either where it will only scroll through history matching a substring in your history, for instance if I type "rg -i" and then start pressing up arrow, it will only cycle through history entries starting with "rg -i".

This is a readline feature. You can enable it in bash (and other shells?) with:

bind '"\e[A": history-search-backward'

bind '"\e[B": history-search-forward'

Re: Small programming tricks

#199

Earlier quoted context omitted.

Another one, not quite as handy but still awesome: ctrl s / ctrl-q. This freezes/unfreezes the terminal output so you can read it, without interrupting your program. Useful for very fast walls of text.

Oh so that is what this is for. I thought ctrl-q / ctrl-s are there as a nasty way to screw with users, who every now and then accidentally press one of these, and find their terminal frozen and no longer visibly reacting to input, for no apparent reason.

You can disable this misbegotten feature with

stty -ixon

Re: Small programming tricks

#200
post #160
post #77

The thing with a lot of these tricks is that you have to get into the habit of using them. I knew `Ctrl+r` for history since I learned about the command line. I even have a nice shell integration with fzf. But I still used the up/down arrow keys for years or scrolled up when I was looking for a previous command, because I never remembered the shortcut and just took the path of least resistance to find something. Usua…

You just have to do it so often that you’re annoyed by it and then you learn the shortcut and then you force yourself to always do the shortcut.

That's how I learned Emacs!
Post reply on HN