Last active
July 16, 2016 02:30
-
-
Save mnemnion/b587b001b397106c639912a5c1f511ef to your computer and use it in GitHub Desktop.
The essential 'jump' family of bash functions
This file contains 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
#Essential jump code | |
export MARKPATH=$HOME/.marks | |
#jump to a directory | |
function jump { | |
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1" | |
} | |
#mark the current directory as a jump destination | |
function mark { | |
mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1" | |
} | |
#remove a mark | |
function unmark { | |
rm -i "$MARKPATH/$1" | |
} | |
#print current marks | |
function marks { | |
\ls -l "$MARKPATH" | tail -n +2 | sed 's/ / /g' | cut -d' ' -f9- | awk -F ' -> ' '{printf "%-10s -> %s\n", $1, $2}' | |
} | |
#shorthand for jump | |
function jp { | |
jump $1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment