pj.plugin.zsh 613 Bytes
Newer Older
1
alias pjo="pj open"
Toon Claes's avatar
Toon Claes committed
2

3
function pj () {
Toon Claes's avatar
Toon Claes committed
4
5
6
7
    cmd="cd"
    file=$1

    if [[ "open" == "$file" ]] then
8
9
        shift
        file=$*
Toon Claes's avatar
Toon Claes committed
10
        cmd=(${(s: :)EDITOR})
11
12
    else
        file=$*
Toon Claes's avatar
Toon Claes committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    fi

    for project in $PROJECT_PATHS; do
        if [[ -d $project/$file ]] then
            $cmd "$project/$file"
            unset project # Unset project var
            return
        fi
    done

    echo "No such project $1"
}

function _pj () {
Marc Cornellà's avatar
Marc Cornellà committed
27
28
    emulate -L zsh

29
    typeset -a projects
Marc Cornellà's avatar
Marc Cornellà committed
30
31
32
33
34
    for basedir ($PROJECT_PATHS); do
        projects+=(${basedir}/*(/N))
    done

    compadd ${projects:t}
Toon Claes's avatar
Toon Claes committed
35
36
}
compdef _pj pj