diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2019-06-16 22:21:13 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2019-06-17 07:04:42 +0530 |
commit | 794a0e27091b63f997fc829d0288cde5a4a2edbd (patch) | |
tree | 384695218b8cf09700df81715627004124e0edf7 /misc/auto-completion | |
parent | aa56b99326a12f5bbab6d5a693755060e81e44a2 (diff) | |
download | nnn-794a0e27091b63f997fc829d0288cde5a4a2edbd.tar.gz |
Move scripts to misc
Diffstat (limited to 'misc/auto-completion')
-rw-r--r-- | misc/auto-completion/bash/nnn-completion.bash | 44 | ||||
-rw-r--r-- | misc/auto-completion/fish/nnn.fish | 18 | ||||
-rw-r--r-- | misc/auto-completion/zsh/_nnn | 25 |
3 files changed, 87 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 diff --git a/misc/auto-completion/fish/nnn.fish b/misc/auto-completion/fish/nnn.fish new file mode 100644 index 0000000..c0a6b1f --- /dev/null +++ b/misc/auto-completion/fish/nnn.fish @@ -0,0 +1,18 @@ +# +# Fish completion definition for nnn. +# +# Author: +# Arun Prakash Jana <engineerarun@gmail.com> +# + +complete -c nnn -s b -r -d 'bookmark key to open' +complete -c nnn -s d -d 'show hidden files' +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 'copy selection to file' +complete -c nnn -s s -d 'use substring match for filters' +complete -c nnn -s S -d 'start in disk usage analyzer mode' +complete -c nnn -s v -d 'show program version and exit' +complete -c nnn -s w -d 'wild load' diff --git a/misc/auto-completion/zsh/_nnn b/misc/auto-completion/zsh/_nnn new file mode 100644 index 0000000..17d1c1a --- /dev/null +++ b/misc/auto-completion/zsh/_nnn @@ -0,0 +1,25 @@ +#compdef nnn +# +# Completion definition for nnn. +# +# Author: +# Arun Prakash Jana <engineerarun@gmail.com> +# + +setopt localoptions noshwordsplit noksharrays +local -a args +args=( + '(-b)-b[bookmark key to open]:key char' + '(-d)-d[show hidden files]' + '(-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[copy selection to file]:file name' + '(-s)-s[use substring match for filters]' + '(-S)-S[start in disk usage analyzer mode]' + '(-v)-v[show program version and exit]' + '(-w)-w[wild load]' + '*:filename:_files' +) +_arguments -S -s $args |