Skip to content

Instantly share code, notes, and snippets.

@pjaspers
Created April 16, 2010 13:14
Show Gist options
  • Save pjaspers/368394 to your computer and use it in GitHub Desktop.
Save pjaspers/368394 to your computer and use it in GitHub Desktop.
Autocomplete zsh projects folder
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
@pjaspers
Copy link
Author

Awesome. Thx !

@To1ne
Copy link

To1ne commented Feb 5, 2013

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.

@johnjohndoe
Copy link

@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