sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

nnn-completion.bash (1621B)


      1 #
      2 # Rudimentary Bash completion definition for nnn.
      3 #
      4 # Author:
      5 #   Arun Prakash Jana <engineerarun@gmail.com>
      6 #
      7 
      8 _nnn ()
      9 {
     10     COMPREPLY=()
     11     local IFS=$'\n'
     12     local cur=$2 prev=$3
     13     local -a opts
     14     opts=(
     15         -a
     16         -A
     17         -b
     18         -B
     19         -c
     20         -C
     21         -d
     22         -D
     23         -e
     24         -E
     25         -f
     26         -g
     27         -H
     28         -i
     29         -J
     30         -K
     31         -l
     32         -n
     33         -o
     34         -p
     35         -P
     36         -Q
     37         -r
     38         -R
     39         -s
     40         -S
     41         -t
     42         -T
     43         -u
     44         -U
     45         -V
     46         -x
     47         -h
     48     )
     49     if [[ $prev == -b ]]; then
     50         local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
     51         COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
     52     elif [[ $prev == -l ]]; then
     53         return 1
     54     elif [[ $prev == -p ]]; then
     55         COMPREPLY=( $(compgen -f -d -- "$cur") )
     56     elif [[ $prev == -P ]]; then
     57         local plugins=$(echo $NNN_PLUG | awk -F: -v RS=\; '{print $1}')
     58         COMPREPLY=( $(compgen -W "$plugins" -- "$cur") )
     59     elif [[ $prev == -s ]]; then
     60         local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions
     61         COMPREPLY=( $(cd "$sessions_dir" && compgen -f -d -- "$cur") )
     62     elif [[ $prev == -t ]]; then
     63         return 1
     64     elif [[ $prev == -T ]]; then
     65         local keys=$(echo "a d e r s t v" | awk -v RS=' ' '{print $0}')
     66         COMPREPLY=( $(compgen -W "$keys" -- "$cur") )
     67     elif [[ $cur == -* ]]; then
     68         COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
     69     else
     70         COMPREPLY=( $(compgen -f -d -- "$cur") )
     71     fi
     72 }
     73 
     74 complete -o filenames -F _nnn nnn