Skip to content

Instantly share code, notes, and snippets.

@asalant
Created August 19, 2013 23:53
Show Gist options
  • Save asalant/6275543 to your computer and use it in GitHub Desktop.
Save asalant/6275543 to your computer and use it in GitHub Desktop.
Command line bookmarks for zsh on OSX from http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html. I put marks.sh in ~/.zsh and source it from ~/.zshrc.
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}'
}
function _completemarks {
reply=($(ls $MARKPATH))
}
compctl -K _completemarks jump
compctl -K _completemarks unmark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment