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.
 
 
 
 
 
 

62 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. -C
  18. -d
  19. -e
  20. -E
  21. -f
  22. -F
  23. -g
  24. -H
  25. -K
  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 == -p ]]; then
  44. COMPREPLY=( $(compgen -f -d -- "$cur") )
  45. elif [[ $prev == -s ]]; then
  46. local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions
  47. COMPREPLY=( $(cd "$sessions_dir" && compgen -f -d -- "$cur") )
  48. elif [[ $prev == -t ]]; then
  49. return 1
  50. elif [[ $prev == -T ]]; then
  51. local keys=$(echo "a d e r s t v" | awk -v RS=' ' '{print $0}')
  52. COMPREPLY=( $(compgen -W "$keys" -- "$cur") )
  53. elif [[ $cur == -* ]]; then
  54. COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
  55. else
  56. COMPREPLY=( $(compgen -f -d -- "$cur") )
  57. fi
  58. }
  59. complete -o filenames -F _nnn nnn