Browse Source

Bash auto-complete enhancements

master
Arun Prakash Jana 5 years ago
parent
commit
427c4b2429
No known key found for this signature in database GPG Key ID: A75979F35C080412
1 changed files with 12 additions and 18 deletions
  1. +12
    -18
      misc/auto-completion/bash/nnn-completion.bash

+ 12
- 18
misc/auto-completion/bash/nnn-completion.bash View File

@@ -9,7 +9,7 @@ _nnn () {
COMPREPLY=() COMPREPLY=()
local IFS=$' \n' local IFS=$' \n'
local cur=$2 prev=$3 local cur=$2 prev=$3
local -a opts opts_with_args local -a opts
opts=( opts=(
-b -b
-d -d
@@ -23,22 +23,16 @@ _nnn () {
-v -v
-w -w
) )
opts_with_arg=( if [[ $prev == -b ]]; then
-b local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
-p COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
) elif [[ $prev == -p ]]; then

COMPREPLY=( $(compgen -f -d -- "$cur") )
# Do not complete non option names elif [[ $cur == -* ]]; then
[[ $cur == -* ]] || return 1 COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )

else
# Do not complete when the previous arg is an option expecting an argument COMPREPLY=( $(compgen -f -d -- "$cur") )
for opt in "${opts_with_arg[@]}"; do fi
[[ $opt == $prev ]] && return 1
done

# Complete option names
COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
return 0
} }


complete -F _nnn nnn complete -o filenames -F _nnn nnn

||||||
x
 
000:0
Loading…
Cancel
Save