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

35 lines
511 B
Bash
Raw Normal View History

alias pjo="pj open"
2013-02-05 16:45:00 +08:00
2022-01-05 16:23:27 +08:00
function pj() {
local cmd="cd"
local 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
2013-02-05 16:45:00 +08:00
fi
2022-01-05 16:23:27 +08:00
done
2013-02-05 16:45:00 +08:00
2022-01-05 16:23:27 +08:00
echo "No such project '${project}'."
2013-02-05 16:45:00 +08:00
}
_pj () {
2022-01-05 16:23:27 +08:00
local -a projects
for basedir ($PROJECT_PATHS); do
projects+=(${basedir}/*(/N))
done
2022-01-05 16:23:27 +08:00
compadd ${projects:t}
2013-02-05 16:45:00 +08:00
}
2022-01-05 16:23:27 +08:00
2013-02-05 16:45:00 +08:00
compdef _pj pj