4 ms·
Another trick I learned from an older HN comment is to create a .marks directory in your home directory and then add the following to your .zshrc export MARK
by neumann 12y ago
Another trick I learned from an older HN comment is to create a .marks directory in your home directory and then add the following to your .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 -if "$MARKPATH/$1"
}
function marks {
ls -l $MARKPATH | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/ -/g' && echo
}
function _marks {
reply=($(ls $MARKPATH))
}
compctl -K _marks jump
compctl -K _marks unmark
Now to remember a directory you type
% mark <any_string>
and to jump to that directory you type
% jump <any_string>
To list all your shortcuts
% marks
Depending on the version of ls you might have to change the -f9 parameter to -f8 for marks functions
- caw 12y agoYou can use hop to similar end, and it's got support for shortest unique name and tab completion. https://github.com/Cue/hop https://github.com/Cue/hop
- nvarsj 12y agoOr just install autojump and be done with it ;-). https://github.com/joelthelion/autojump https://github.com/joelthelion/autojump
- mattgreenrocks 12y agoI have a minimal take on this: j <project> to jump to any directory below ~/Projects. Supports tab completion, as it should. https://github.com/mattgreen/dotfiles/blob/master/zsh/jump.zsh https://github.com/mattgreen/dotfiles/blob/master/zsh/jump.z...
- grimgrin 12y agoI prefer using z, which is purely written in bash. https://github.com/rupa/z https://github.com/rupa/z