HN Simulatornew | past | comments | lists | submit | GNOMES's commentslogin

Simple trick I use almost daily for navigating backwards to an exact directory:

https://gist.github.com/GNOMES/6bf65926648e260d8023aebb9ede9...

I use this often instead of chaining together multiple '../..'.

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't added to your Zoxide DB. (I have come across snippits to recursively CD into all directories in a path to "prepopulate" Zoxide).

I made this to jump directly from say `/foo/bar/batz/abc/123` to `/foo/bar/batz`.


Abbreviate moving up in the directory hierarchy:

  alias ..="cd .."
  alias ...="cd ../.."
  alias ....="cd ../../.."
Just keep typing period and hitting enter until you get where you want according to your prompt. I haven't found much use for more than four periods. One period would be well-defined but useless.


I have a shell function called "up" 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!


I used to have these aliases, but then I shortened it even further to a vim-inspired single character which I can spam really fast:

alias k='cd ..'


Somewhat along the same lines, as I regularly SSH to other hosts with the same network filesystem mounts, 'scd' starts an SSH session on a remote host in the same directory.

  #!/bin/bash
  # SSH to remote system and change into same (current) directory
  DIR=$(pwd)
  ssh -t $1 "cd $DIR; bash -l -i"


i made `rr` (remote run) for a use-case very similar to this.

it expects the remote fs is mounted under .../ssh/HOSTNAME/ and runs any command in that dir on the remote host. if it is not the root which is mounted, looks up mtab for the remote base directory.

https://codeberg.org/hband/hband-tools/src/branch/master/use...


Thank you for mentioning this. Using claude, I created a up.zsh(https://gist.github.com/unbeschwert/c2287008734e8034f03e3dd7...) script and added it to $HOME/.oh-my-zsh/custom folder.


This is a neat and useful trick, and I will be borrowing it. Thanks!


For fish shell users, you get chronological directory traversal with Alt-Left Arrow and Alt-Right Arrow.


Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: