From 564eafbeb333bd5b81e4ecb46cd798a21544d852 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sat, 2 Sep 2017 12:23:19 +0530 Subject: Add auto-completion scripts --- scripts/auto-completion/bash/nnn-completion.bash | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 scripts/auto-completion/bash/nnn-completion.bash (limited to 'scripts/auto-completion/bash') diff --git a/scripts/auto-completion/bash/nnn-completion.bash b/scripts/auto-completion/bash/nnn-completion.bash new file mode 100644 index 0000000..b16b296 --- /dev/null +++ b/scripts/auto-completion/bash/nnn-completion.bash @@ -0,0 +1,41 @@ +# +# Rudimentary Bash completion definition for nnn. +# +# Author: +# Arun Prakash Jana +# + +_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 -- cgit v1.2.3-70-g09d2