ohmyzsh/plugins/pj/pj.plugin.zsh

44 lines
721 B
Bash
Raw Normal View History

alias pjo="pj open"
2013-02-05 09:45:00 +01:00
pj () {
emulate -L zsh
setopt shwordsplit
2013-02-05 09:45:00 +01:00
cmd="cd"
project=$1
2013-02-05 09:45:00 +01:00
if [[ "open" == "$project" ]]; then
shift
project=$*
cmd=$EDITOR
else
project=$*
2013-02-05 09:45:00 +01:00
fi
if [[ -z "$project" ]]; then
echo "You have to specify a project name."
return
fi
for basedir ($PROJECT_PATHS); do
if [[ -d "$basedir/$project" ]]; then
$cmd "$basedir/$project"
2013-02-05 09:45:00 +01:00
return
fi
done
echo "No such project '${project}'."
2013-02-05 09:45:00 +01:00
}
_pj () {
emulate -L zsh
typeset -a projects
for basedir ($PROJECT_PATHS); do
projects+=(${basedir}/*(/N))
done
compadd ${projects:t}
2013-02-05 09:45:00 +01:00
}
compdef _pj pj