‹ BackHN Continuity

Thread

Small programming tricks

681 points · 294 comments · signa11

  1. phforms · · focus · HN ↗
    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.

    Usually what I do is writing these tricks down to a document that is easily accessible at a place where I know that I will look for when failing to remember them. I have a directory of docs where I write stuff like this down by language/tool/etc., so I can quickly look it up without having to search the internet. But I also have to actively remind myself that these things exist whenever I have a problem, stop me from just doing the inefficient thing.

    1. quirino · · focus · HN ↗
      atuin kind of fixes this habit, when you click up you get a list of the latest commands, and you can just start typing to search. It's extremely natural.
      1. ChickeNES · · focus · HN ↗
        I found atuin way too hard/slow to use, I think I went two days before I nuked it and went back to pure omzsh. Has it gotten any better in the past 2ish years?
        1. ellieh · · focus · HN ↗
          (hi! I work on atuin!)

          yes, it's improved a lot in the last couple of years! what in particular bothered you?

          1. saghm · · focus · HN ↗
            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 tomorrow I'll try it out again and see if it's still something I encounter.
            1. ellieh · · focus · HN ↗
              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

              1. saghm · · focus · HN ↗
                Good to hear! Sounds like my history file might not even be that large compared to your tests now
              2. ChickeNES · · focus · HN ↗
                I'm curious, is using the daemon with my own frontend a supported use case? Because I had a thought...while as I mentioned above I don't use the CLI much anymore...my agents do, and having that history in a sql db would be mighty useful...

                Edit: Okay, y'all are literally working on exactly what I need to build off of, perfect lmao

                1. ellieh · · focus · HN ↗
                  we actually have an mcp built on top of this that you can use, no problem!
            2. ChickeNES · · focus · HN ↗
              I think it was a combo of this + completely screwing my muscle memory haha. I'd give it another shot...but tbh, these days claude/codex are more my command line than bash/zsh.
              1. saghm · · focus · HN ↗
                I'm running into this again now that I'm trying it. I also have the unfortunate habit of sometimes trying to do stuff in the terminal via remote connection over a streaming server from my SteamOS handheld, and in the desktop input layout I have defined, I can really easily hit the up arrow with my thumbstick, whereas any modifier shortcuts need to be defined manually. From glancing through the config file, there does seem to be a lot of customization though, so I think it might still be viable if I can find a sweet spot in how to define the settings.
        2. zem · · focus · HN ↗
          I've been using it happily for longer than that! I do remember having to tweak the default search behaviours when I first installed it but it's been largely problem free ever since.
      2. SAI_Peregrinus · · focus · HN ↗
        Or you can start typing and press up arrow to search with that. Atuin (or some Zsh extensions, etc.) fix the bad UI of having to remember a different key for "search history by order and text" and "search history by order".
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.