mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Add auto-completion scripts
This commit is contained in:
parent
277cf66097
commit
564eafbeb3
|
@ -26,6 +26,7 @@ Noice is Not Noice, a noicer fork...
|
||||||
- [From a package manager](#from-a-package-manager)
|
- [From a package manager](#from-a-package-manager)
|
||||||
- [Release packages](#release-packages)
|
- [Release packages](#release-packages)
|
||||||
- [From source](#from-source)
|
- [From source](#from-source)
|
||||||
|
- [Shell completion](#shell-completion)
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [Cmdline options](#cmdline-options)
|
- [Cmdline options](#cmdline-options)
|
||||||
- [Keyboard shortcuts](#keyboard-shortcuts)
|
- [Keyboard shortcuts](#keyboard-shortcuts)
|
||||||
|
@ -160,6 +161,10 @@ To cook yourself, download the [latest stable release](https://github.com/jarun/
|
||||||
|
|
||||||
`PREFIX` is supported, in case you want to install to a different location.
|
`PREFIX` is supported, in case you want to install to a different location.
|
||||||
|
|
||||||
|
### Shell completion
|
||||||
|
|
||||||
|
Search keyword and option completion scripts for Bash, Fish and Zsh can be found in respective subdirectories of [`scripts/auto-completion/`](scripts/auto-completion). Please refer to your shell's manual for installation instructions.
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
#### Cmdline options
|
#### Cmdline options
|
||||||
|
|
41
scripts/auto-completion/bash/nnn-completion.bash
Normal file
41
scripts/auto-completion/bash/nnn-completion.bash
Normal file
|
@ -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
|
15
scripts/auto-completion/fish/nnn.fish
Normal file
15
scripts/auto-completion/fish/nnn.fish
Normal file
|
@ -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'
|
22
scripts/auto-completion/zsh/_nnn
Normal file
22
scripts/auto-completion/zsh/_nnn
Normal file
|
@ -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
|
Loading…
Reference in a new issue