diff options
| author | 2019-08-22 19:58:39 +0530 | |
|---|---|---|
| committer | 2019-08-23 08:30:48 +0530 | |
| commit | 9feb5ce6512c9a5b1e6658d0ea408f5c19332b2c (patch) | |
| tree | 5ad703522600829982eca71ee93e9f85b0292f86 | |
| parent | 0fbd68ab48b38319f3f3d516ef4d04d7274db4ac (diff) | |
| download | nnn-9feb5ce6512c9a5b1e6658d0ea408f5c19332b2c.tar.gz | |
Merge fzy-edit into fzy-open
| -rw-r--r-- | plugins/README.md | 3 | ||||
| -rwxr-xr-x | plugins/fzy-edit | 8 | ||||
| -rwxr-xr-x | plugins/fzy-open | 13 |
3 files changed, 12 insertions, 12 deletions
diff --git a/plugins/README.md b/plugins/README.md index d666240..47a7aab 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -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 index 6155250..0000000 --- a/plugins/fzy-edit +++ /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)" 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 |