1 # Easily jump around the file system by manually adding marks
2 # marks are stored as symbolic links in the directory $MARKPATH (default $HOME/.marks)
4 # jump FOO: jump to a mark named FOO
5 # mark FOO: create a mark named FOO
6 # unmark FOO: delete a mark
7 # marks: lists all marks
9 export MARKPATH=$HOME/.marks
12 builtin cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
16 if [[ $# -eq 0 || "$1" = "." ]]; then
21 if read -q "?Mark $PWD as ${MARK}? (y/n) "; then
22 command mkdir -p "$MARKPATH"
23 command ln -sfn "$PWD" "$MARKPATH/$MARK"
28 LANG= command rm -i "$MARKPATH/$1"
33 for link in $MARKPATH/{,.}*(@N); do
34 if [[ ${#link:t} -gt $max ]]; then
38 local printf_markname_template="$(printf -- "%%%us " "$max")"
39 for link in $MARKPATH/{,.}*(@N); do
40 local markname="$fg[cyan]${link:t}$reset_color"
41 local markpath="$fg[blue]$(readlink $link)$reset_color"
42 printf -- "$printf_markname_template" "$markname"
43 printf -- "-> %s\n" "$markpath"
48 reply=("${MARKPATH}"/{,.}*(@N:t))
50 compctl -K _completemarks jump
51 compctl -K _completemarks unmark
54 setopt localoptions extendedglob
55 autoload -U modify-current-argument
56 modify-current-argument '$(readlink "$MARKPATH/$ARG" || echo "$ARG")'
58 zle -N _mark_expansion
59 bindkey "^g" _mark_expansion