dotfiles/zsh/.local/share/oh-my-zsh/.oh-my-zsh/plugins/pj/pj.plugin.zsh

35 lines
511 B
Bash
Raw Normal View History

2024-06-19 00:06:56 +02:00
alias pjo="pj open"
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
fi
done
echo "No such project '${project}'."
}
_pj () {
local -a projects
for basedir ($PROJECT_PATHS); do
projects+=(${basedir}/*(/N))
done
compadd ${projects:t}
}
compdef _pj pj