diff options
Diffstat (limited to 'misc/auto-completion/bash/nnn-completion.bash')
-rw-r--r-- | misc/auto-completion/bash/nnn-completion.bash | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/misc/auto-completion/bash/nnn-completion.bash b/misc/auto-completion/bash/nnn-completion.bash new file mode 100644 index 0000000..4c81e77 --- /dev/null +++ b/misc/auto-completion/bash/nnn-completion.bash @@ -0,0 +1,44 @@ +# +# 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=( + -b + -d + -e + -h + -i + -l + -p + -s + -S + -v + -w + ) + opts_with_arg=( + -b + -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 |