jump.plugin.zsh 969 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
# Easily jump around the file system by manually adding marks
# marks are stored as symbolic links in the directory $MARKPATH (default $HOME/.marks)
#
# jump FOO: jump to a mark named FOO
# mark FOO: create a mark named FOO
# unmark FOO: delete a mark
# marks: lists all marks
#
export MARKPATH=$HOME/.marks
10

11
function jump {
12
	cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
13
}
14

15
function mark {
16
	mkdir -p "$MARKPATH"; ln -s "$(pwd)" $MARKPATH/$1
17
}
18

19
function unmark {
20
	rm -i "$MARKPATH/$1"
21
}
22

23
function marks {
24
	ls -l "$MARKPATH" | sed 's/  / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo
25
}
26
27

function _completemarks {
Justin Aiken's avatar
Justin Aiken committed
28
  reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_\da-zA-Z\-]*):$/\2/g'))
29
30
31
}
compctl -K _completemarks jump
compctl -K _completemarks unmark
32
33
34
35
36
37
38
39

_mark_expansion() {
	setopt extendedglob
	autoload -U modify-current-argument
	modify-current-argument '$(readlink "$MARKPATH/$ARG")'
}
zle -N _mark_expansion
bindkey "^g" _mark_expansion