mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
preview-tui: fix tmux behaviour, del refs to nuke (#559)
As reported by @toddyamakawa
This commit is contained in:
parent
5b34d0dbe7
commit
f438ddc28c
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
# Note: This plugin needs a "NNN_FIFO" to work.
|
# Note: This plugin needs a "NNN_FIFO" to work.
|
||||||
#
|
#
|
||||||
# Dependencies: tmux or xterm (or set $TERMINAL), file, tree
|
# Dependencies: tmux (>=3.0) or xterm (or set $TERMINAL), file, tree
|
||||||
#
|
#
|
||||||
# How to use:
|
# How to use:
|
||||||
# You need to set a NNN_FIFO path and set a key for the plugin,
|
# You need to set a NNN_FIFO path and set a key for the plugin,
|
||||||
|
@ -21,18 +21,14 @@
|
||||||
# Authors: Todd Yamakawa and Léo Villeveygoux
|
# Authors: Todd Yamakawa and Léo Villeveygoux
|
||||||
|
|
||||||
TERMINAL="${TERMINAL:-xterm}"
|
TERMINAL="${TERMINAL:-xterm}"
|
||||||
NUKE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/nuke"
|
|
||||||
|
|
||||||
if [ ! -r "$NNN_FIFO" ] ; then
|
|
||||||
echo "No FIFO available! (\$NNN_FIFO='$NNN_FIFO')" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ ! -x "$NUKE" ] ; then
|
|
||||||
echo "Nuke not found!" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$PREVIEW_MODE" ] ; then
|
if [ "$PREVIEW_MODE" ] ; then
|
||||||
|
if [ ! -r "$NNN_FIFO" ] ; then
|
||||||
|
echo "No FIFO available! (\$NNN_FIFO='$NNN_FIFO')" >&2
|
||||||
|
read -r
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
exec < "$NNN_FIFO"
|
exec < "$NNN_FIFO"
|
||||||
while read -r selection ; do
|
while read -r selection ; do
|
||||||
clear
|
clear
|
||||||
|
@ -40,7 +36,7 @@ if [ "$PREVIEW_MODE" ] ; then
|
||||||
cols=$(tput cols)
|
cols=$(tput cols)
|
||||||
mime="$(file -b --mime-type "$selection")"
|
mime="$(file -b --mime-type "$selection")"
|
||||||
|
|
||||||
if [ "$mime" = "inode/directory" ] ; then
|
if [ -d "$selection" ]; then
|
||||||
# Print directory tree
|
# Print directory tree
|
||||||
cd "$selection" && tree | head -n $lines | cut -c 1-"$cols"
|
cd "$selection" && tree | head -n $lines | cut -c 1-"$cols"
|
||||||
elif [ "${mime%%/*}" = "text" ] ; then
|
elif [ "${mime%%/*}" = "text" ] ; then
|
||||||
|
@ -52,17 +48,11 @@ if [ "$PREVIEW_MODE" ] ; then
|
||||||
file -b "$selection"
|
file -b "$selection"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -e "${TMUX%%,*}" ] ; then
|
|
||||||
tmux kill-pane
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "${TMUX%%,*}" ] ; then
|
if [ -e "${TMUX%%,*}" ] && [ "$(tmux -V | cut -c6)" -eq 3 ] ; then
|
||||||
tmux split-window -e "NNN_FIFO=$NNN_FIFO" -e "PREVIEW_MODE=1" -dh "$0"
|
tmux split-window -e "NNN_FIFO=$NNN_FIFO" -e "PREVIEW_MODE=1" -dh "$0"
|
||||||
else
|
else
|
||||||
PREVIEW_MODE=1 GUI=0 $TERMINAL -e "$0" &
|
PREVIEW_MODE=1 $TERMINAL -e "$0" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue