3 ms·
Simple trick I use almost daily for navigating backwards to an exact directory: https://gist.github.com/GNOMES/6bf65926648e260d8023aebb9ede9573 https://gist.gi
by GNOMES 18d ago
Simple trick I use almost daily for navigating backwards to an exact directory:
https://gist.github.com/GNOMES/6bf65926648e260d8023aebb9ede9573 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`.
- exdeejay_ 18d agoThis is a neat and useful trick, and I will be borrowing it. Thanks!
- RhysU 18d agoAbbreviate 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.
- segfaltnh 17d agoI 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!
- nandkeypull 16d agoI 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 ..'
- zh3 17d agoSomewhat 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"
- bandie91 17d agoi 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/user-tools/rr https://codeberg.org/hband/hband-tools/src/branch/master/use...
- urxvtcd 17d agoFor fish shell users, you get chronological directory traversal with Alt-Left Arrow and Alt-Right Arrow.
- pretty_dumm_guy 17d agoThank you for mentioning this. Using claude, I created a up.zsh(https://gist.github.com/unbeschwert/c2287008734e8034f03e3dd7119a167b https://gist.github.com/unbeschwert/c2287008734e8034f03e3dd7...) script and added it to $HOME/.oh-my-zsh/custom folder.