Skip to content

Instantly share code, notes, and snippets.

@samuelleach
Created August 20, 2013 08:39
Show Gist options
  • Save samuelleach/6278795 to your computer and use it in GitHub Desktop.
Save samuelleach/6278795 to your computer and use it in GitHub Desktop.
Bash configuration script for jumping around your file system.
# 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"
}
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- && echo
}
function _jump {
local cur=${COMP_WORDS[COMP_CWORD]}
local marks=$(find $MARKPATH -type l | awk -F '/' '{print $NF}')
COMPREPLY=($(compgen -W '${marks[@]}' -- "$cur"))
return 0
}
complete -o default -o nospace -F _jump jump
@samuelleach
Copy link
Author

Via [1] and Hackernews.
Bash configuration script for jumping around your file system. eg

$ cd /my/very/long/path

$ mark path

$ marks
path -> /my/very/long/path

jump path

[1] http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment