Created
February 19, 2011 01:21
-
-
Save rpetrich/834726 to your computer and use it in GitHub Desktop.
Shell Bookmarks for Bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# shell bookmarks; s <name> to save, l to list and g <name> to go | |
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 "^.*=" | sort | |
} | |
function g { | |
source ~/.sdirs | |
cd $(eval $(echo echo $(echo \$DIR_$1))) | |
} | |
# enable custom tab completion on g | |
shopt -s progcomp | |
function _l { | |
source ~/.sdirs | |
env | grep "^DIR_" | cut -c5- | grep "^.*=" | cut -f1 -d "=" | |
} | |
function _gcomp { | |
local curw | |
COMPREPLY=() | |
curw=${COMP_WORDS[COMP_CWORD]} | |
COMPREPLY=($(compgen -W '`_l`' -- $curw)) | |
return 0 | |
} | |
complete -F _gcomp g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment