‹ 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. lelandbatey · · focus · HN ↗
      It&#x27;s quite true. Years ago, after `git switch` was released, I wanted to try to switch from `git checkout` to `git switch`. Ultimately I had to set up some bash nastiness to error and &quot;scold&quot; me when I typed `git checkout` from memory, while still allowing shell scripts to call `git checkout` just fine. It was a fun exercise, and at least now I know how I could do it again: <a href="https:&#x2F;&#x2F;github.com&#x2F;lelandbatey&#x2F;dotfiles&#x2F;blob&#x2F;99c08f81fc8971035cc47a1fce3510db3401b26d&#x2F;.bashrc#L259-L263" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lelandbatey&#x2F;dotfiles&#x2F;blob&#x2F;99c08f81fc89710...
      1. irishcoffee · · focus · HN ↗
        Your beef is with git, which is terrible, not a shell.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.