Created
August 22, 2014 20:08
-
-
Save pdex/3d941158ff085258617c to your computer and use it in GitHub Desktop.
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
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