Skip to content

Instantly share code, notes, and snippets.

@StanAngeloff
Created August 30, 2010 22:34
Show Gist options
  • Select an option

  • Save StanAngeloff/558158 to your computer and use it in GitHub Desktop.

Select an option

Save StanAngeloff/558158 to your computer and use it in GitHub Desktop.
ZSH_BOOKMARKS="$HOME/.zsh/cdbookmarks"
function cdb_edit() {
$EDITOR "$ZSH_BOOKMARKS"
}
function cdb() {
local index
local entry
index=0
for entry in $(echo "$1" | tr '/' '\n'); do
if [[ $index == "0" ]]; then
local CD
CD=$(egrep "^$entry\\s" "$ZSH_BOOKMARKS" | sed "s#^$entry\\s\+##")
if [ -z "$CD" ]; then
echo "$0: no such bookmark: $entry"
break
else
cd "$CD"
fi
else
cd "$entry"
if [ "$?" -ne "0" ]; then
break
fi
fi
let "index++"
done
}
function _cdb() {
reply=(`cat "$ZSH_BOOKMARKS" | sed -e 's#^\(.*\)\s.*$#\1#g'`)
}
compctl -K _cdb cdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment