1
1
mirror of https://github.com/jarun/nnn.git synced 2024-11-12 21:41:22 +03:00

Pistol support (#646)

This commit is contained in:
Mario 2020-06-10 02:41:57 +02:00 committed by GitHub
parent 9130db3e75
commit 7b68844a05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,6 +21,10 @@
# 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" &