4 ms·
Very nice. I use a set of bash functions to do the same thing, with tab-autocompletion (not my own development, I picked it up from the web somewhere long ago)
by harel 10y ago
Very nice.
I use a set of bash functions to do the same thing, with tab-autocompletion (not my own development, I picked it up from the web somewhere long ago). Put this in your .bashrc:
# mark/jump support + completion
# un/mark name : bookmark a directory or remove one (unmark)
# jump name : jump to directory
# marks : show all bookmarks
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 | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo
}
_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
- ihowlatthemoon 10y agoThis is brilliant. Added immediately. It's something I never realized I needed until I found out about it. Thank you.
- harel 10y agoThat's exactly what I said when i found out about it. Its just one of those things....
- bollu 10y agooh, interesting! I don't have a deep understanding of how bash auto-completion works, I'll read through this to adapt it. I'm glad you liked it :)