Skip to content

Instantly share code, notes, and snippets.

@pdex
Created August 22, 2014 20:08
Show Gist options
  • Save pdex/3d941158ff085258617c to your computer and use it in GitHub Desktop.
Save pdex/3d941158ff085258617c to your computer and use it in GitHub Desktop.
export MARKPATH=$HOME/.marks.d
function jump {
if [[ -z "$1" ]]; then
echo "usage: jump markname"
else
if [[ -L "$MARKPATH/$1" ]]; then
cd -P "$MARKPATH/$1" 2>/dev/null
else
echo "No such mark: '$1'"
fi
fi
}
function mark {
if [[ -z "$1" ]]; then
echo "usage: mark markname"
else
ln -si "$(pwd)" "$MARKPATH/$1"
fi
}
function unmark {
if [[ -z "$1" ]]; then
echo "usage: unmark markname"
else
rm -i "$MARKPATH/$1"
fi
}
function marks {
ls "$MARKPATH"
}
if [[ ! -d "$MARKPATH" ]]; then
mkdir -p "$MARKPATH"
fi
_completemarks() {
local curw=${COMP_WORDS[COMP_CWORD]}
local wordlist=$(ls "$MARKPATH")
COMPREPLY=($(compgen -W '${wordlist[@]}' -- "$curw"))
return 0
}
complete -F _completemarks jump unmark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment