Skip to content

Instantly share code, notes, and snippets.

@mnemnion
Last active July 16, 2016 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnemnion/b587b001b397106c639912a5c1f511ef to your computer and use it in GitHub Desktop.
Save mnemnion/b587b001b397106c639912a5c1f511ef to your computer and use it in GitHub Desktop.
The essential 'jump' family of bash functions
#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