My build of nnn with minor changes
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

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