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