Quantcast
Viewing all articles
Browse latest Browse all 10

bash directory bookmarks with autocompletion

Just stick this in your ~/.bashrc

declare -A bookmarks
bookmarks["myproject"]="/home/user/projects/folder/myproject"
bookmarks["tmp"]="/tmp"
keys=${!bookmarks[@]}
function bm {
if [ -z $1 ];then return; fi
local directory=${bookmarks[$1]}
if [ -n "$directory" ];then
cd $directory
else
echo "Directory does not exist"
fi
}
complete -W '$keys' bm

Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 10

Trending Articles