ohmyzsh/plugins/pj/pj.plugin.zsh

35 lines
511 B
Bash
Raw Normal View History

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