Created
April 16, 2010 13:14
-
-
Save pjaspers/368394 to your computer and use it in GitHub Desktop.
Autocomplete zsh projects folder
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
function go() { | |
if [[ -e ~/development/rails/$1 ]]; then | |
cd ~/development/rails/$1 | |
elif [[ -e ~/development/sinatra/$1 ]]; then | |
cd ~/development/sinatra/$1 | |
elif [[ -e ~/development/objc/$1 ]]; then | |
cd ~/development/objc/$1 | |
elif [[ -e ~/development/php/$1 ]]; then | |
cd ~/development/php/$1 | |
elif [[ -e ~/development/ruby/$1 ]]; then | |
cd ~/development/ruby/$1 | |
else | |
cd | |
fi | |
} | |
_go_list_need_generating () { | |
if [ ! -f ~/.projectlist~ ]; then return 0; | |
else | |
return 1; | |
fi | |
} | |
_go () { | |
if _go_list_need_generating; then | |
echo "\nGenerating ~/.projectlist~..." > /dev/stderr | |
for f in ~/development/*; do ls $f | cat >> ~/.projectlist~; done | |
fi | |
compadd `cat ~/.projectlist~` | |
} | |
compdef _go go |
Awesome. Thx !
I've turned this into an oh-my-zsh plugin and requested a pull:
ohmyzsh/ohmyzsh#1583
I've renamed it to pj
to avoid a name clash with the GO programming language.
@To1ne Please add a README to the folder of oh-my-zsh.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My implementation of the same code: