1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-22 13:50:09 +00:00
ohmyzsh/plugins/pj/pj.plugin.zsh

35 lines
511 B
Bash
Raw Normal View History

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