2016-08-10 13:35:40 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-08-11 01:33:36 +02:00
|
|
|
_pj () {
|
2022-01-05 09:23:27 +01:00
|
|
|
local -a projects
|
|
|
|
for basedir ($PROJECT_PATHS); do
|
|
|
|
projects+=(${basedir}/*(/N))
|
|
|
|
done
|
2016-08-11 01:35:45 +02:00
|
|
|
|
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
|