by kkoncevicius · 3y ago · 0 comments
mkdir ~/.marks/
export CDPATH=.:~/.marks/
function mark { ln -sr "$(pwd)" ~/.marks/"$1"; }
Then: mark @name # add bookmark called @name for the current directory
cd @name # jump to the bookmarked location
cd @<tab> # list all available bookmarks
It can list bookmarks, auto-complete, jump to sub-directories within bookmarks, all without introducing any new commands - just `cd`.[1]: http://karolis.koncevicius.lt/posts/fast_navigation_in_the_c...
It sure took me ages to figure it was CDPATH, but CDPATH it is. I won't retry without making that "cd @" thing a subfunction (that might involve making its own completion, but that's easy compared to debugging make... I still don't know WHY it broke, just that it's CDPATH that broke it -- it decided to duplicate the subdir arg when invoking a submake so make was now left with a weird unknown target, but it obviously wouldn't say that and just failed weirdly)
If all these causes the build to fail then the maintainers of that build should be informed.
This is useful for two things - 1) avoiding clashes with existing directories, 2) having a quick command to list all the bookmarks: cd @<tab>
I gave up on bookmarking so I now use an alias to quickly find what I am looking for with fzf and fd:
p () { cd $(fd $1 $HOME -d 4 -i -E Pictures -E Desktop | fzf) }https://til.hashrocket.com/posts/xsavbhlrz4-shortcuts-with-h...