summaryrefslogtreecommitdiff
path: root/community/apparix/apparix.sh
blob: 9bad62b82fca9a4c8fc24684d75b4a628aa08c65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52


function to()
{
   if test "$2"; then
     cd "$(apparix "$1" "$2" || echo .)";
   else
     cd "$(apparix "$1" || echo .)";
   fi
   pwd
}

function bm()
{
   if test "$2"; then
      apparix --add-mark "$1" "$2";
   elif test "$1"; then
      apparix --add-mark "$1";
   else
      apparix --add-mark;
   fi
}

function portal()
{
   if test "$1"; then
      apparix --add-portal "$1";
   else
      apparix --add-portal;
   fi
}

function _apparix_aliases ()
{   cur=$2
    dir=$3
    COMPREPLY=()
    if [ "$1" == "$3" ]
    then
        COMPREPLY=($(cat $HOME/.apparix{rc,expand}|grep "j,.*$cur.*,"|cut -f2 -d,))
    else
        dir=`apparix -favour lro $dir 2>/dev/null` || return 0
        eval_compreply="
        COMPREPLY=( $(cd "$dir" ; ls -d *$cur* |
            while read r
            do
                [[ -d "$r" ]] && [[ $r == *$cur* ]] && echo \"${r// /\\ }\"
            done))"
        eval $eval_compreply
    fi
    return 0
}
complete -F _apparix_aliases to