diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2017-09-02 12:23:19 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2017-09-02 12:23:19 +0530 |
commit | 564eafbeb333bd5b81e4ecb46cd798a21544d852 (patch) | |
tree | bf6fa36db9945a0685124d38f837870439d0ccc2 /scripts/auto-completion | |
parent | 277cf66097209b0f56312e11a82dd3db437df1a0 (diff) | |
download | nnn-564eafbeb333bd5b81e4ecb46cd798a21544d852.tar.gz |
Add auto-completion scripts
Diffstat (limited to 'scripts/auto-completion')
-rw-r--r-- | scripts/auto-completion/bash/nnn-completion.bash | 41 | ||||
-rw-r--r-- | scripts/auto-completion/fish/nnn.fish | 15 | ||||
-rw-r--r-- | scripts/auto-completion/zsh/_nnn | 22 |
3 files changed, 78 insertions, 0 deletions
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 <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 diff --git a/scripts/auto-completion/fish/nnn.fish b/scripts/auto-completion/fish/nnn.fish new file mode 100644 index 0000000..2eebc48 --- /dev/null +++ b/scripts/auto-completion/fish/nnn.fish @@ -0,0 +1,15 @@ +# +# Fish completion definition for nnn. +# +# Author: +# Arun Prakash Jana <engineerarun@gmail.com> +# + +complete -c nnn -s c -r -d 'specify dir color, disables if N>7' +complete -c nnn -s e -d 'use exiftool instead of mediainfo' +complete -c nnn -s h -d 'show this help and exit' +complete -c nnn -s i -d 'start in navigate-as-you-type mode' +complete -c nnn -s l -d 'start in light mode (fewer details)' +complete -c nnn -s p -r -d 'specify custom nlay' +complete -c nnn -s S -d 'start in disk usage analyzer mode' +complete -c nnn -s v -d 'show program version and exit' diff --git a/scripts/auto-completion/zsh/_nnn b/scripts/auto-completion/zsh/_nnn new file mode 100644 index 0000000..8dfe053 --- /dev/null +++ b/scripts/auto-completion/zsh/_nnn @@ -0,0 +1,22 @@ +#compdef nnn +# +# Completion definition for nnn. +# +# Author: +# Arun Prakash Jana <engineerarun@gmail.com> +# + +setopt localoptions noshwordsplit noksharrays +local -a args +args=( + '(-c)-c[specify dir color, disables if N>7]:color code' + '(-e)-e[use exiftool instead of mediainfo]' + '(-h)-h[show this help and exit]' + '(-i)-i[start in navigate-as-you-type mode]' + '(-l)-l[start in light mode (fewer details)]' + '(-p)-p[specify custom nlay]:path to nlay' + '(-S)-S[start in disk usage analyzer mode]' + '(-v)-v[show program version and exit]' + '*: :_guard "^-*" keyword' +) +_arguments -S -s $args |