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.

nnn-completion.bash 1022 B

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