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