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