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

68 行
1.5 KiB

  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. -e
  19. -E
  20. -f
  21. -F
  22. -g
  23. -H
  24. -K
  25. -l
  26. -n
  27. -o
  28. -p
  29. -P
  30. -Q
  31. -r
  32. -R
  33. -s
  34. -S
  35. -t
  36. -T
  37. -V
  38. -x
  39. -h
  40. )
  41. if [[ $prev == -b ]]; then
  42. local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
  43. COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
  44. elif [[ $prev == -l ]]; then
  45. return 1
  46. elif [[ $prev == -p ]]; then
  47. COMPREPLY=( $(compgen -f -d -- "$cur") )
  48. elif [[ $prev == -P ]]; then
  49. local plugins=$(echo $NNN_PLUG | awk -F: -v RS=\; '{print $1}')
  50. COMPREPLY=( $(compgen -W "$plugins" -- "$cur") )
  51. elif [[ $prev == -s ]]; then
  52. local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions
  53. COMPREPLY=( $(cd "$sessions_dir" && compgen -f -d -- "$cur") )
  54. elif [[ $prev == -t ]]; then
  55. return 1
  56. elif [[ $prev == -T ]]; then
  57. local keys=$(echo "a d e r s t v" | awk -v RS=' ' '{print $0}')
  58. COMPREPLY=( $(compgen -W "$keys" -- "$cur") )
  59. elif [[ $cur == -* ]]; then
  60. COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
  61. else
  62. COMPREPLY=( $(compgen -f -d -- "$cur") )
  63. fi
  64. }
  65. complete -o filenames -F _nnn nnn