]> Sergey Matveev's repositories - nnn.git/commitdiff
Merge fzy-edit into fzy-open
authorArun Prakash Jana <engineerarun@gmail.com>
Thu, 22 Aug 2019 14:28:39 +0000 (19:58 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 23 Aug 2019 03:00:48 +0000 (08:30 +0530)
plugins/README.md
plugins/fzy-edit [deleted file]
plugins/fzy-open

index d666240ff4143ba1219f6baeda13ae54c050b317..47a7aab04924343890e81a82d06c80d220ccb479 100644 (file)
@@ -6,8 +6,7 @@ The currently available plugins are listed below.
 | --- | --- | --- | --- |
 | boom | sh | SMPlayer | Play random music from dir (modify `PLAYER`) |
 | checksum | sh | md5sum,<br>sha256sum | Create and verify checksums |
-| fzy-edit | sh | fzy | Fuzzy find a file in directory subtree and edit in vim |
-| fzy-open | sh | fzy | Fuzzy find a file in directory subtree and open using xdg-open |
+| fzy-open | sh | fzy, xdg-open | Fuzzy find a file in dir subtree and edit or xdg-open |
 | getplugs | sh | wget | Update plugins |
 | hexview | sh | xxd | View a file in hex in `$PAGER` |
 | imgresize | sh | [imgp](https://github.com/jarun/imgp) | Resize images in directory to screen resolution |
diff --git a/plugins/fzy-edit b/plugins/fzy-edit
deleted file mode 100755 (executable)
index 6155250..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env sh
-
-# Description: Fuzzy find a file in directory subtree with fzy and edit in vim
-#
-# Shell: POSIX compliant
-# Author: Arun Prakash Jana
-
-vim "$(find -type f | fzy)"
index 0ddd229397354c46e4e424bc4dd0fe69281b4c71..a2fbb89e122776bdc85b602b9f7643bcaa2f56e8 100755 (executable)
@@ -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