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.
 
 
 
 
 
 

30 lines
868 B

  1. #!/usr/bin/env sh
  2. # Description: Fuzzy find a file in directory subtree with fzy
  3. # Opens in $VISUAL or $EDITOR if text
  4. # Opens other type of files with xdg-open
  5. #
  6. # Requires: fzf/fzy, xdg-open
  7. #
  8. # Shell: POSIX compliant
  9. # Author: Arun Prakash Jana
  10. if which fzf >/dev/null 2>&1; then
  11. cmd="$FZF_DEFAULT_COMMAND"
  12. [ -z "$cmd" ] && cmd="find . -type f 2>/dev/null"
  13. entry="$(eval "$cmd" | fzf --delimiter / --nth=-1 --tiebreak=begin --info=hidden)"
  14. # To show only the file name
  15. # entry=$(find . -type f 2>/dev/null | fzf --delimiter / --with-nth=-1 --tiebreak=begin --info=hidden)
  16. elif which fzy >/dev/null 2>&1; then
  17. entry=$(find . -type f 2>/dev/null | fzy)
  18. else
  19. exit 1
  20. fi
  21. case "$(file -biL "$entry")" in
  22. *text*)
  23. "${VISUAL:-$EDITOR}" "$entry" ;;
  24. *)
  25. xdg-open "$entry" >/dev/null 2>&1 ;;
  26. esac