Skip to content

Instantly share code, notes, and snippets.

@lajlev
Last active December 21, 2015 06:49
Show Gist options
  • Save lajlev/6267234 to your computer and use it in GitHub Desktop.
Save lajlev/6267234 to your computer and use it in GitHub Desktop.
mark autocomplete error
### "mark" functionality http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
export MARKPATH=$HOME/.marks
function jump {
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
}
function mark {
mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1"
}
function unmark {
rm -i "$MARKPATH/$1"
}
function marks {
\ls -l "$MARKPATH" | tail -n +2 | sed 's/ / /g' | cut -d' ' -f9- | awk -F ' -> ' '{printf "%-10s -> %s\n", $1, $2}'
}
# If mac use this wordlist instead
# local wordlist=$(ls $MARKPATH)
_completemarks() {
local curw=${COMP_WORDS[COMP_CWORD]}
local wordlist=$(find $MARKPATH -type l -printf "%f\n")
COMPREPLY=($(compgen -W '${wordlist[@]}' -- "$curw"))
return 0
}
complete -F _completemarks jump unmark
### "Mark" end
### get this error http://i.laj.lv/image/160K2m362T1l
@DanielMM
Copy link

Works like a charm and I added an alias to my .profile_aliases file just to make it even faster to use.
alias j="jump"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment