My build of nnn with minor changes
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

nnn-completion.bash 1.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. -H
  22. -i
  23. -K
  24. -n
  25. -o
  26. -p
  27. -r
  28. -R
  29. -s
  30. -S
  31. -t
  32. -v
  33. -h
  34. )
  35. if [[ $prev == -b ]]; then
  36. local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
  37. COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
  38. elif [[ $prev == -p ]]; then
  39. COMPREPLY=( $(compgen -f -d -- "$cur") )
  40. elif [[ $prev == -e ]]; then
  41. local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions
  42. COMPREPLY=( $(cd "$sessions_dir" && compgen -f -d -- "$cur") )
  43. elif [[ $cur == -* ]]; then
  44. COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
  45. else
  46. COMPREPLY=( $(compgen -f -d -- "$cur") )
  47. fi
  48. }
  49. complete -o filenames -F _nnn nnn