aboutsummaryrefslogtreecommitdiff
path: root/q.sh
blob: e76365712b5721df4b29013ac9d69ebfadd3900a (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
# snippets to wire up qroject into bash nicely.

enable -f ~/qroject/target/release/libqroject_bash.so q qi qg qd

function qcmdcomp() {
  # for qg, qg, qi, the first and only argument is
  # the project name.
  if [ "$1" = "$3" ]; then
    COMPREPLY=($(q list "$2"))
  fi
}

function qcomp() {
  case "$3" in
    add)
      COMPREPLY=($(compgen -A file "$2"))
      ;;
    info | upstream | go | dir | edit | list)
      COMPREPLY=($(q list "$2"))
      ;;
    q)
      COMPREPLY=(add info upstream go dir edit list)
      ;;
    *)
      COMPREPLY=($(compgen -A file "$2"))
      ;;
  esac
}

complete -F qcomp q
complete -F qcmdcomp qg
complete -F qcmdcomp qd
complete -F qcmdcomp qi