Created
August 25, 2013 17:43
-
-
Save alanwsmith/6335221 to your computer and use it in GitHub Desktop.
A version of Jeroen Janssens' "Quickly navigate your filesystem from the command-line" code (including autocomplete) setup for a Mac running OS X 10.8 and a ZSH shell. (Note that I've changed the name of the 'jump' command to 'jt' to make it shorter and easier to type.) Original article: http://jeroenjanssens.com/2013/08/16/quickly-navigate-your…
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
# Based on: Quickly navigate your filesystem from the command-line | |
# http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html | |
# by Jeroen Janssens | |
# Notes: | |
# - This version is for Mac OSX 10.8 using ZSH. | |
# - It includes autocomplete functionality. | |
# - The original 'jump' command changed to 'jt' (think Jump To). | |
# - Marks are stored in '~/.jumptomarks' instead of '~/.marks'. | |
# - The '~/.jumptomarks' dir is created automatically by using 'mark' | |
# Usage: | |
# | |
# To create a mark, cd into the directory then run: | |
# mark somename | |
# | |
# To quickly jump to a directory that has been marked, use: | |
# jt somename | |
# | |
# Remove a mark with: | |
# unmark somename | |
# | |
# List all current marks with: | |
# marks | |
export MARKPATH=$HOME/.jumptomarks | |
function jt { | |
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" | tail -n +2 | sed 's/ / /g' | cut -d' ' -f9- | awk -F ' -> ' '{printf "%-10s -> %s\n", $1, $2}' | |
} | |
function _completemarks { | |
reply=($(ls $MARKPATH)) | |
} | |
compctl -K _completemarks jt | |
compctl -K _completemarks unmark | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use the original "jump" command name, change "jt" go "jump" on lines 29 and 46. (If you want to update the documentation, change it on line 18 and then delete line 8 too.)