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.
 
 
 
 
 
 

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