]> Sergey Matveev's repositories - nnn.git/commitdiff
Pistol support (#646)
authorMario <marioortizmanero@gmail.com>
Wed, 10 Jun 2020 00:41:57 +0000 (02:41 +0200)
committerGitHub <noreply@github.com>
Wed, 10 Jun 2020 00:41:57 +0000 (06:11 +0530)
plugins/preview-tui

index 86260eb289f49cb42483f60210ced5e4268378a7..7b4a7a0aa818eec47b5769bd776a1d11352ebb45 100755 (executable)
 #                To use:
 #                1. drop scope.sh executable in $PATH
 #                2. set/export $USE_SCOPE as 1
+#    - optional: pistol file viewer (https://github.com/doronbehar/pistol).
+#                To use:
+#                1. install pistol
+#                2. set/export $USE_PISTOL as 1
 #
 # Usage:
 #   You need to set a NNN_FIFO path and a key for the plugin with NNN_PLUG,
@@ -57,6 +61,7 @@
 SPLIT="$SPLIT"  # you can set a permanent split here
 TERMINAL="$TERMINAL"  # same goes for the terminal
 USE_SCOPE="${USE_SCOPE:-0}"
+USE_PISTOL="${USE_PISTOL:-0}"
 PAGER="${PAGER:-less -R}"
 
 if [ -e "${TMUX%%,*}" ] && tmux -V | grep -q '[ -][3456789]\.'; then
@@ -120,6 +125,12 @@ preview_file () {
     lines=$(($(tput lines)-1))
     cols=$(tput cols)
 
+    # Trying to use pistol if it's available.
+    if [ "$USE_PISTOL" -ne 0 ] && exists pistol; then
+        fifo_pager pistol "$1"
+        return
+    fi
+
     # Trying to use scope.sh if it's available.
     if [ "$USE_SCOPE" -ne 0 ] && exists scope.sh; then
         fifo_pager scope.sh "$1" "$cols" "$lines" "$(mktemp -d)" \
@@ -209,6 +220,7 @@ elif [ "$TERMINAL" = "kitty" ]; then
           --cwd "$PWD" --env "PATH=$PATH" --env "NNN_FIFO=$NNN_FIFO" \
           --env "PREVIEW_MODE=1" --env "PAGER=$PAGER" \
           --env "USE_SCOPE=$USE_SCOPE" --env "SPLIT=$SPLIT" \
+          --env "USE_PISTOL=$USE_PISTOL" \
           --location "${SPLIT}split" "$0" "$1" >/dev/null
 else
     PREVIEW_MODE=1 $TERMINAL -e "$0" "$1" &