From ef0e9731345b020eccbb67d511d958bc92f7fb89 Mon Sep 17 00:00:00 2001
From: Arun Prakash Jana <engineerarun@gmail.com>
Date: Wed, 10 Jun 2020 22:33:59 +0530
Subject: [PATCH] Add hx as alternative hex viewer

---
 plugins/README.md | 2 +-
 plugins/hexview   | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/plugins/README.md b/plugins/README.md
index 14eb9765..9cdaa2a3 100644
--- a/plugins/README.md
+++ b/plugins/README.md
@@ -41,7 +41,7 @@ Plugins are installed to `${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins`.
 | [getplugs](getplugs) | Update plugins to installed `nnn` version | sh | curl |
 | [gutenread](gutenread) | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m<br>[epr](https://github.com/wustho/epr) (optional) |
 | [gpg\*](gpg\*) | Encrypt/decrypt files using GPG | sh | gpg |
-| [hexview](hexview) | View a file in hex in `$PAGER` | sh | xxd |
+| [hexview](hexview) | View a file in hex in `$PAGER` | sh | [hx](https://github.com/krpors/hx)/xxd |
 | [imgresize](imgresize) | Resize images in dir to screen resolution | sh | [imgp](https://github.com/jarun/imgp) |
 | [imgthumb](imgthumb) | View thumbnail of an image or dir of images | sh | [lsix](https://github.com/hackerb9/lsix) |
 | [imgur](imgur) | Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) | bash | - |
diff --git a/plugins/hexview b/plugins/hexview
index 60b34281..ce17a60d 100755
--- a/plugins/hexview
+++ b/plugins/hexview
@@ -1,11 +1,15 @@
 #!/usr/bin/env sh
 
 # Description: View a file in hex
-# Dependencies: xxd and $PAGER
+# Dependencies: hx (https://github.com/krpors/hx)/xxd and $PAGER
 #
 # Shell: POSIX compliant
 # Author: Arun Prakash Jana
 
 if ! [ -z "$1" ]; then
-    xxd "$1" | $PAGER
+    if which hx >/dev/null 2>&1; then
+        hx "$1"
+    else
+        xxd "$1" | $PAGER
+    fi
 fi
-- 
2.51.0