bec53135e4
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
43 lines
701 B
Bash
43 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
|