ohmyzsh/plugins/pj/pj.plugin.zsh
Marc Cornellà bec53135e4 Fix shwordsplit bug when a basedir contains spaces
The `shwordsplit` option affects all variables and we only need to split
the `$EDITOR` variable. Because of that, using `${=spec}` is a much better
alternative.

More info at
http://zsh.sourceforge.net/Doc/Release/Expansion.html#index-SH_005fWORD_005fSPLIT_002c-toggle
2016-08-16 08:32:43 +02:00

42 lines
701 B
Bash

alias pjo="pj open"
pj () {
emulate -L zsh
cmd="cd"
project=$1
if [[ "open" == "$project" ]]; then
shift
project=$*
cmd=${=EDITOR}
else
project=$*
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"
return
fi
done
echo "No such project '${project}'."
}
_pj () {
emulate -L zsh
typeset -a projects
for basedir ($PROJECT_PATHS); do
projects+=(${basedir}/*(/N))
done
compadd ${projects:t}
}
compdef _pj pj