sistema_progs

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

nnn-completion.bash (1610B)


      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         -c
     19         -C
     20         -d
     21         -D
     22         -e
     23         -E
     24         -f
     25         -g
     26         -H
     27         -i
     28         -J
     29         -K
     30         -l
     31         -n
     32         -o
     33         -p
     34         -P
     35         -Q
     36         -r
     37         -R
     38         -s
     39         -S
     40         -t
     41         -T
     42         -u
     43         -U
     44         -V
     45         -x
     46         -h
     47     )
     48     if [[ $prev == -b ]]; then
     49         local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
     50         COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
     51     elif [[ $prev == -l ]]; then
     52         return 1
     53     elif [[ $prev == -p ]]; then
     54         COMPREPLY=( $(compgen -f -d -- "$cur") )
     55     elif [[ $prev == -P ]]; then
     56         local plugins=$(echo $NNN_PLUG | awk -F: -v RS=\; '{print $1}')
     57         COMPREPLY=( $(compgen -W "$plugins" -- "$cur") )
     58     elif [[ $prev == -s ]]; then
     59         local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions
     60         COMPREPLY=( $(cd "$sessions_dir" && compgen -f -d -- "$cur") )
     61     elif [[ $prev == -t ]]; then
     62         return 1
     63     elif [[ $prev == -T ]]; then
     64         local keys=$(echo "a d e r s t v" | awk -v RS=' ' '{print $0}')
     65         COMPREPLY=( $(compgen -W "$keys" -- "$cur") )
     66     elif [[ $cur == -* ]]; then
     67         COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
     68     else
     69         COMPREPLY=( $(compgen -f -d -- "$cur") )
     70     fi
     71 }
     72 
     73 complete -o filenames -F _nnn nnn