‹ BackHN Continuity

Thread

Small programming tricks

681 points · 294 comments · signa11

  1. GNOMES · · focus · HN ↗
    Simple trick I use almost daily for navigating backwards to an exact directory:

    <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;GNOMES&#x2F;6bf65926648e260d8023aebb9ede9573" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;GNOMES&#x2F;6bf65926648e260d8023aebb9ede9...

    I use this often instead of chaining together multiple &#x27;..&#x2F;..&#x27;.

    Also nice for when I use Zoxide to CD into a deep nested directory. I quickly found out unless you manually CD each hop, the different parent directories aren&#x27;t added to your Zoxide DB. (I have come across snippits to recursively CD into all directories in a path to &quot;prepopulate&quot; Zoxide).

    I made this to jump directly from say `&#x2F;foo&#x2F;bar&#x2F;batz&#x2F;abc&#x2F;123` to `&#x2F;foo&#x2F;bar&#x2F;batz`.

    1. RhysU · · focus · HN ↗
      Abbreviate moving up in the directory hierarchy:

        alias ..=&quot;cd ..&quot;
        alias ...=&quot;cd ..&#x2F;..&quot;
        alias ....=&quot;cd ..&#x2F;..&#x2F;..&quot;
      
      Just keep typing period and hitting enter until you get where you want according to your prompt. I haven&#x27;t found much use for more than four periods. One period would be well-defined but useless.
      1. segfaltnh · · focus · HN ↗
        I have a shell function called &quot;up&quot; that finds a project root and jumps back to it (e.g. a dir containing something like .git)

        Now I have these to complement - thanks!

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.