nnn/plugins/fzy-open

18 lines
429 B
Text
Raw Normal View History

2019-01-03 23:05:51 +05:30
#!/usr/bin/env sh
2019-08-22 19:58:39 +05:30
# 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 23:05:51 +05:30
#
# Shell: POSIX compliant
2019-01-03 23:05:51 +05:30
# Author: Arun Prakash Jana
2019-10-04 20:46:57 +05:30
entry="$(find -type f 2>/dev/null | fzy)"
2019-08-22 19:58:39 +05:30
case "$(file -biL "$entry")" in
*text*)
"${VISUAL:-$EDITOR}" "$entry" ;;
*)
xdg-open "$entry" >/dev/null 2>&1 ;;
esac