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.
 
 
 
 
 
 

36 lines
639 B

  1. #!/usr/bin/env sh
  2. # Description: Run fzf and go to the directory of the file selected
  3. #
  4. # Shell: POSIX compliant
  5. # Author: Anna Arad
  6. . "$(dirname "$0")"/.nnn-plugin-helper
  7. if [ "$(cmd_exists fzy)" -eq "0" ]; then
  8. if [ "$(cmd_exists fd)" -eq "0" ]; then
  9. fd=fd
  10. elif [ "$(cmd_exists fdfind)" -eq "0" ]; then
  11. fd=fdfind
  12. else
  13. fd=find
  14. fi
  15. sel=$($fd | fzy)
  16. elif [ "$(cmd_exists fzf)" -eq "0" ]; then
  17. sel=$(fzf --print0)
  18. else
  19. exit 1
  20. fi
  21. if ! [ -z "$sel" ]; then
  22. case "$(file -bi "$sel")" in
  23. *directory*) ;;
  24. *) sel=$(dirname "$sel") ;;
  25. esac
  26. # Remove "./" prefix
  27. sel="$(echo "$sel" | cut -c 3-)"
  28. nnn_cd "$PWD/$sel"
  29. fi