2020-05-24
A two-line solution for bookmarking directories and navigating them with cd
.
Create .marks/
folder within home directory and add this to .bashrc:
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 @name/subidr # jump to a subdirectory within bookmarked location
cd @n<tab> # auto-complete a bookmark
cd @<tab> # list all available bookmarks
Note: prefixing bookmarks with a special symbol like "@" avoids interference with directories in the current folder.
A zero-line solution for maintaining a list of "bookmarks".
If bookmarks are only kept for active projects directory structure can be adjusted instead:
└── work
├── active_project_1/
├── active_project_2/
├── todo.txt
└── zzz/
├── inactive_project_1/
├── inactive_project_2/
├── inactive_project_3/
├── inactive_project_4/
└── ...
Note: frequently accessed directories are placed under work/
and are transferred to zzz/
once unnecessary.