1
0
Fork 0
mirror of https://github.com/jarun/nnn.git synced 2025-02-19 07:41:21 +00:00
nnn/misc/auto-completion/bash/nnn-completion.bash

75 lines
1.6 KiB
Bash
Raw Normal View History

2017-09-02 12:23:19 +05:30
#
# Rudimentary Bash completion definition for nnn.
#
# Author:
# Arun Prakash Jana <engineerarun@gmail.com>
#
2019-11-22 02:14:25 +05:30
_nnn ()
{
2017-09-02 12:23:19 +05:30
COMPREPLY=()
local IFS=$'\n'
2017-09-02 12:23:19 +05:30
local cur=$2 prev=$3
2019-07-08 23:35:30 +05:30
local -a opts
2017-09-02 12:23:19 +05:30
opts=(
-a
-A
2018-12-09 08:36:00 +05:30
-b
-B
2019-10-06 18:57:15 +05:30
-c
-C
2019-03-11 20:24:44 +05:30
-d
2020-09-01 23:06:26 +05:30
-D
-e
2019-11-30 18:14:39 +05:30
-E
-f
2019-12-14 19:00:09 +05:30
-g
2019-08-16 23:15:29 +05:30
-H
-i
2020-09-01 23:06:26 +05:30
-J
2019-10-11 20:59:22 +05:30
-K
-l
2019-07-14 23:00:14 +05:30
-n
-o
2018-12-09 08:36:00 +05:30
-p
-P
2019-12-14 23:28:13 +05:30
-Q
-r
2019-12-01 23:00:06 +05:30
-R
-s
2017-09-02 12:23:19 +05:30
-S
-t
2020-03-18 02:35:05 +05:30
-T
2021-03-17 23:06:08 +05:30
-u
-U
-V
-x
2019-08-16 23:15:29 +05:30
-h
2017-09-02 12:23:19 +05:30
)
2019-07-08 23:35:30 +05:30
if [[ $prev == -b ]]; then
local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
elif [[ $prev == -l ]]; then
return 1
2019-07-08 23:35:30 +05:30
elif [[ $prev == -p ]]; then
COMPREPLY=( $(compgen -f -d -- "$cur") )
elif [[ $prev == -P ]]; then
local plugins=$(echo $NNN_PLUG | awk -F: -v RS=\; '{print $1}')
COMPREPLY=( $(compgen -W "$plugins" -- "$cur") )
elif [[ $prev == -s ]]; then
local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions
COMPREPLY=( $(cd "$sessions_dir" && compgen -f -d -- "$cur") )
elif [[ $prev == -t ]]; then
return 1
2020-03-18 02:35:05 +05:30
elif [[ $prev == -T ]]; then
local keys=$(echo "a d e r s t v" | awk -v RS=' ' '{print $0}')
COMPREPLY=( $(compgen -W "$keys" -- "$cur") )
2019-07-08 23:35:30 +05:30
elif [[ $cur == -* ]]; then
COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
else
COMPREPLY=( $(compgen -f -d -- "$cur") )
fi
2017-09-02 12:23:19 +05:30
}
2019-07-08 23:35:30 +05:30
complete -o filenames -F _nnn nnn