My build of nnn with minor changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

70 lines
1.5 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. -A
  16. -b
  17. -c
  18. -C
  19. -d
  20. -e
  21. -E
  22. -f
  23. -F
  24. -g
  25. -H
  26. -K
  27. -l
  28. -n
  29. -o
  30. -p
  31. -P
  32. -Q
  33. -r
  34. -R
  35. -s
  36. -S
  37. -t
  38. -T
  39. -V
  40. -x
  41. -h
  42. )
  43. if [[ $prev == -b ]]; then
  44. local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
  45. COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
  46. elif [[ $prev == -l ]]; then
  47. return 1
  48. elif [[ $prev == -p ]]; then
  49. COMPREPLY=( $(compgen -f -d -- "$cur") )
  50. elif [[ $prev == -P ]]; then
  51. local plugins=$(echo $NNN_PLUG | awk -F: -v RS=\; '{print $1}')
  52. COMPREPLY=( $(compgen -W "$plugins" -- "$cur") )
  53. elif [[ $prev == -s ]]; then
  54. local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions
  55. COMPREPLY=( $(cd "$sessions_dir" && compgen -f -d -- "$cur") )
  56. elif [[ $prev == -t ]]; then
  57. return 1
  58. elif [[ $prev == -T ]]; then
  59. local keys=$(echo "a d e r s t v" | awk -v RS=' ' '{print $0}')
  60. COMPREPLY=( $(compgen -W "$keys" -- "$cur") )
  61. elif [[ $cur == -* ]]; then
  62. COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
  63. else
  64. COMPREPLY=( $(compgen -f -d -- "$cur") )
  65. fi
  66. }
  67. complete -o filenames -F _nnn nnn