nnn/plugins/fzopen

18 lines
429 B
Plaintext
Raw Normal View History

2019-01-03 17:35:51 +00:00
#!/usr/bin/env sh
2019-08-22 14:28:39 +00:00
# Description: Fuzzy find a file in directory subtree with fzy
# Opens in $VISUAL or $EDITOR if text
# Opens other type of files with xdg-open
2019-01-03 17:35:51 +00:00
#
# Shell: POSIX compliant
2019-01-03 17:35:51 +00:00
# Author: Arun Prakash Jana
2019-10-04 15:16:57 +00:00
entry="$(find -type f 2>/dev/null | fzy)"
2019-08-22 14:28:39 +00:00
case "$(file -biL "$entry")" in
*text*)
"${VISUAL:-$EDITOR}" "$entry" ;;
*)
xdg-open "$entry" >/dev/null 2>&1 ;;
esac