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.
 
 
 
 
 
 

48 line
1022 B

  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