mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-12 08:50:08 +00:00
7f8851f52f
- Use `emulate -L zsh` to make all variables local. - Use `shwordsplit` to interpret `$cmd` spaces correctly. - Rename `$project` and `$file` variables to the more appropriate `$basedir` and `$project`.
38 lines
614 B
Bash
38 lines
614 B
Bash
alias pjo="pj open"
|
|
|
|
pj () {
|
|
emulate -L zsh
|
|
setopt shwordsplit
|
|
|
|
cmd="cd"
|
|
project=$1
|
|
|
|
if [[ "open" == "$project" ]]; then
|
|
shift
|
|
project=$*
|
|
cmd=$EDITOR
|
|
else
|
|
project=$*
|
|
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
|