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.
 
 
 
 
 
 

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