소스 검색

Bash auto-complete enhancements

master
Arun Prakash Jana 5 년 전
부모
커밋
427c4b2429
No known key found for this signature in database GPG 키 ID: A75979F35C080412
1개의 변경된 파일12개의 추가작업 그리고 18개의 파일을 삭제
  1. +12
    -18
      misc/auto-completion/bash/nnn-completion.bash

+ 12
- 18
misc/auto-completion/bash/nnn-completion.bash 파일 보기

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

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

불러오는 중...
취소
저장