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

nnn-completion.bash 1.0 KiB

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