productivity helper : bash utility
I found a handy utility download here for bookmarking in the terminal. It basically lets you save bookmarks of your current location by name for easy retrieval.
Usage:
cd <directory_you_visit_a_lot> s <name> This saves the working directory as a bookmark with the name you gave it. List the current bookmarks by l Jump to a current bookmark g <name> Paste to the bottom of your .bashrc file
function s {
cat ~/.sdirs | grep -v "export DIR_$1=" > ~/.sdirs1
mv ~/.sdirs1 ~/.sdirs
echo "export DIR_$1=$PWD" >> ~/.sdirs
}
function l {
source ~/.sdirs
env | grep "^DIR_" | cut -c5- | grep "^.*="
}
# enable custom tab completion
shopt -s progcomp
# jump to bookmark
function g {
source ~/.sdirs
cd $(eval $(echo echo $(echo \$DIR_$1)))
}
# list bookmarks without dirname
function _l {
source ~/.sdirs
env | grep "^DIR_" | cut -c5- | grep "^.*=" | cut -f1 -d "="
}
# completion command for g
function _gcomp {
local curw
COMPREPLY=()
curw=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -W '`_l`' -- $curw))
return 0
}
# bind completion command for g to _gcomp
complete -F _gcomp g
# Usage: g [TAB]