1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-24 01:33:52 +08:00
ohmyzsh/plugins/pj/pj.plugin.zsh

38 lines
594 B
Bash
Raw Normal View History

alias pjo="pj open"
2013-02-05 16:45:00 +08:00
pj () {
emulate -L zsh
2013-02-05 16:45:00 +08:00
cmd="cd"
project=$1
2013-02-05 16:45:00 +08:00
if [[ "open" == "$project" ]]; then
shift
project=$*
cmd=${=EDITOR}
else
project=$*
2013-02-05 16:45:00 +08:00
fi
for basedir ($PROJECT_PATHS); do
if [[ -d "$basedir/$project" ]]; then
$cmd "$basedir/$project"
2013-02-05 16:45:00 +08:00
return
fi
done
echo "No such project '${project}'."
2013-02-05 16:45:00 +08:00
}
_pj () {
emulate -L zsh
typeset -a projects
for basedir ($PROJECT_PATHS); do
projects+=(${basedir}/*(/N))
done
compadd ${projects:t}
2013-02-05 16:45:00 +08:00
}
compdef _pj pj