From 9feb5ce6512c9a5b1e6658d0ea408f5c19332b2c Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Thu, 22 Aug 2019 19:58:39 +0530 Subject: Merge fzy-edit into fzy-open --- plugins/fzy-open | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'plugins/fzy-open') diff --git a/plugins/fzy-open b/plugins/fzy-open index 0ddd229..a2fbb89 100755 --- a/plugins/fzy-open +++ b/plugins/fzy-open @@ -1,8 +1,17 @@ #!/usr/bin/env sh -# Description: Fuzzy find a file in directory subtree with fzy and open using xdg-open +# 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 -xdg-open "$(find -type f | fzy)" >/dev/null 2>&1 +entry="$(find -type f | fzy)" + +case "$(file -biL "$entry")" in + *text*) + "${VISUAL:-$EDITOR}" "$entry" ;; + *) + xdg-open "$entry" >/dev/null 2>&1 ;; +esac -- cgit v1.2.3-70-g09d2