My build of nnn with minor changes
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

4 anos atrás
4 anos atrás
1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env sh
  2. # Description: Fuzzy find a file in directory subtree
  3. # Opens in $VISUAL or $EDITOR if text
  4. # Opens other type of files with xdg-open
  5. #
  6. # Dependencies: fd/find, fzf/skim, 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. if which fd >/dev/null 2>&1; then
  13. [ -z "$cmd" ] && cmd="fd -t f 2>/dev/null"
  14. else
  15. [ -z "$cmd" ] && cmd="find . -type f 2>/dev/null"
  16. fi
  17. entry="$(eval "$cmd" | fzf --delimiter / --nth=-1 --tiebreak=begin --info=hidden)"
  18. # To show only the file name
  19. # entry=$(find . -type f 2>/dev/null | fzf --delimiter / --with-nth=-1 --tiebreak=begin --info=hidden)
  20. elif which sk >/dev/null 2>&1; then
  21. entry=$(find . -type f 2>/dev/null | sk)
  22. else
  23. exit 1
  24. fi
  25. case "$(file -biL "$entry")" in
  26. *text*)
  27. "${VISUAL:-$EDITOR}" "$entry" ;;
  28. *)
  29. if uname | grep -q "Darwin"; then
  30. open "$entry" >/dev/null 2>&1
  31. else
  32. xdg-open "$entry" >/dev/null 2>&1
  33. fi
  34. ;;
  35. esac