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.
 
 
 
 
 
 

61 lines
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. -A
  16. -b
  17. -c
  18. -d
  19. -e
  20. -E
  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