A simple command-line utility to bookmark directories.
- I was tired of
cd
'ing into my frequently visited directories by typing/tab completing the complete path every time. - I wanted to write some shell script 😄.
grep | for searching directories in bookmarks.txt file |
sed | for deleting directory from bookmarks.txt file |
fzf | for fuzzy-finding directories in bookmarks.txt file |
-
Copy
bookmarks.sh
file somewhere in your$PATH
, and make it executable. (I keep the script in~/.local/bin
)for example:
wget https://raw.githubusercontent.com/krish-r/bookmarks.sh/main/bookmarks.sh -O ~/.local/bin/bookmarks.sh # adds executable permission to user chmod u+x ~/.local/bin/bookmarks.sh
-
Simply remove the script from your path and the bookmark file.
for example:
rm -i $(which bookmarks.sh) # The file where the bookmarks will be stored. rm -i ~/.cache/bookmarks.txt
bookmarks.sh
bookmarks.sh -h
# add current directory to bookmarks
bookmarks.sh -a
# add a custom directory to bookmarks
# you can use "~" or "$HOME" to specify your home directory
bookmarks.sh -a "full_path_to_your_directory_within_double_quotes"
Note: Relative paths are not supported
# delete current directory from bookmarks
bookmarks.sh -d
# delete a custom directory from bookmarks
bookmarks.sh -d "full_path_to_your_directory_within_double_quotes"
bookmarks.sh -l
cd $(bookmarks.sh -l)
Add these aliases in your .bashrc
or .zshrc
or wherever you manage your aliases.
if command -v bookmarks.sh &> /dev/null; then
alias badd="bookmarks.sh -a"
alias bdel="bookmarks.sh -d"
alias blist='eval cd $(bookmarks.sh -l)' # use single quotes to evaluate
fi