Last active
January 13, 2018 14:21
-
-
Save shrekuu/c42af56f01f773d5d4520ac1cded18c7 to your computer and use it in GitHub Desktop.
mac command script to quickly jump between bookmarked directories or fallback to "cd" instead quickly :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # quick jump to often used directories | |
| # for linux check the differency mention from: | |
| # http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html | |
| export MARKPATH=$HOME/.marks | |
| function jump { | |
| cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1" | |
| pwd | |
| } | |
| 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}' | |
| } | |
| # tab completion for jump and unmark | |
| function _completemarks { | |
| reply=($(ls $MARKPATH)) | |
| } | |
| compctl -K _completemarks jump | |
| compctl -K _completemarks unmark | |
| # use cdd, so you can fall back to 'cd' instead quickly :) | |
| alias cdd='jump' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment