Commit 7f8851f5 authored by Marc Cornellà's avatar Marc Cornellà
Browse files

Refactor pj function

- Use `emulate -L zsh` to make all variables local.

- Use `shwordsplit` to interpret `$cmd` spaces correctly.

- Rename `$project` and `$file` variables to the more appropriate `$basedir`
  and `$project`.
parent c9c11d60
alias pjo="pj open" alias pjo="pj open"
function pj () { pj () {
emulate -L zsh
setopt shwordsplit
cmd="cd" cmd="cd"
file=$1 project=$1
if [[ "open" == "$file" ]] then if [[ "open" == "$project" ]]; then
shift shift
file=$* project=$*
cmd=(${(s: :)EDITOR}) cmd=$EDITOR
else else
file=$* project=$*
fi fi
for project in $PROJECT_PATHS; do for basedir ($PROJECT_PATHS); do
if [[ -d $project/$file ]] then if [[ -d "$basedir/$project" ]]; then
$cmd "$project/$file" $cmd "$basedir/$project"
unset project # Unset project var
return return
fi fi
done done
echo "No such project $1" echo "No such project '${project}'."
} }
function _pj () { _pj () {
emulate -L zsh emulate -L zsh
typeset -a projects typeset -a projects
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment