My build of nnn with minor changes
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

nnn-completion.bash 781 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #
  2. # Rudimentary Bash completion definition for nnn.
  3. #
  4. # Author:
  5. # Arun Prakash Jana <engineerarun@gmail.com>
  6. #
  7. _nnn () {
  8. COMPREPLY=()
  9. local IFS=$' \n'
  10. local cur=$2 prev=$3
  11. local -a opts
  12. opts=(
  13. -b
  14. -d
  15. -e
  16. -h
  17. -i
  18. -l
  19. -p
  20. -s
  21. -S
  22. -v
  23. -w
  24. )
  25. if [[ $prev == -b ]]; then
  26. local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
  27. COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
  28. elif [[ $prev == -p ]]; then
  29. COMPREPLY=( $(compgen -f -d -- "$cur") )
  30. elif [[ $cur == -* ]]; then
  31. COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
  32. else
  33. COMPREPLY=( $(compgen -f -d -- "$cur") )
  34. fi
  35. }
  36. complete -o filenames -F _nnn nnn