aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/fzy-open
blob: 97da456590288ab1507c168fec72ce6286d5d5b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env sh

# 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
#
# Shell: POSIX compliant
# Author: Arun Prakash Jana

entry="$(find -type f 2>/dev/null | fzy)"

case "$(file -biL "$entry")" in
    *text*)
        "${VISUAL:-$EDITOR}" "$entry" ;;
    *)
        xdg-open "$entry" >/dev/null 2>&1 ;;
esac