mirror of
https://github.com/jarun/nnn.git
synced 2024-11-05 10:53:11 +00:00
42 lines
737 B
Bash
42 lines
737 B
Bash
|
#
|
||
|
# Rudimentary Bash completion definition for nnn.
|
||
|
#
|
||
|
# Author:
|
||
|
# Arun Prakash Jana <engineerarun@gmail.com>
|
||
|
#
|
||
|
|
||
|
_nnn () {
|
||
|
COMPREPLY=()
|
||
|
local IFS=$' \n'
|
||
|
local cur=$2 prev=$3
|
||
|
local -a opts opts_with_args
|
||
|
opts=(
|
||
|
-c
|
||
|
-e
|
||
|
-h
|
||
|
-i
|
||
|
-l
|
||
|
-p
|
||
|
-S
|
||
|
-v
|
||
|
)
|
||
|
opts_with_arg=(
|
||
|
-c
|
||
|
-p
|
||
|
)
|
||
|
|
||
|
# Do not complete non option names
|
||
|
[[ $cur == -* ]] || return 1
|
||
|
|
||
|
# Do not complete when the previous arg is an option expecting an argument
|
||
|
for opt in "${opts_with_arg[@]}"; do
|
||
|
[[ $opt == $prev ]] && return 1
|
||
|
done
|
||
|
|
||
|
# Complete option names
|
||
|
COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
|
||
|
return 0
|
||
|
}
|
||
|
|
||
|
complete -F _nnn nnn
|