mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-29 09:10:07 +00:00
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
42 lines
701 B
Bash
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
|