mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
More minimal bat previews, minor improvements to fzplug (#1004)
* More minimal bat previews, minor improvements to fzplug * Use BAT_STYLE if set, better fzplug formatting * Fix linebreak in single quotes * Fix line numbers in comments * Readability and shellcheck warning * Fix line numbers in comments * Breaking typo * Pre-existing BAT_STYLE would not be honored in tmux
This commit is contained in:
parent
7a76ca8548
commit
b14d2311e6
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
# Description: Fuzzy find and execute nnn plugins (and, optionally, custom scripts located elsewhere).
|
# Description: Fuzzy find and execute nnn plugins (and, optionally, custom scripts located elsewhere).
|
||||||
# Description and details of plugins can be previewed from the fzf interface. Use `?` to toggle preview
|
# Description and details of plugins can be previewed from the fzf interface. Use `?` to toggle preview
|
||||||
# pane on and off.
|
# pane on and off, ^Up/^Dn to scroll.
|
||||||
#
|
#
|
||||||
# For better compatibility with as many nnn plugins as possible, fzfplug will first execute
|
# For better compatibility with as many nnn plugins as possible, fzplug will first execute
|
||||||
# the chosen script on the file hovered in nnn, and upon failure, try to run it with no target
|
# the chosen script on the file hovered in nnn, and upon failure, try to run it with no target
|
||||||
# (i.e on an active selection, if present).
|
# (i.e on an active selection, if present).
|
||||||
#
|
#
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
# Optional scripts sources
|
# Optional scripts sources
|
||||||
# Leave blank or fill with the absolute path of a folder containing executable scripts other than nnn plugins
|
# Leave blank or fill with the absolute path of a folder containing executable scripts other than nnn plugins
|
||||||
# (e.g., "$HOME/.local/share/nautilus/scripts", since there are numerous Nautilus script git repositories).
|
# (e.g., "$HOME/.local/share/nautilus/scripts", since there are numerous Nautilus script git repositories).
|
||||||
# Add extra variables if need be, but be sure to call them in the find command below at lines 28:49 and 30:49.
|
# Add extra variables if need be, but be sure to call them in the find command below at lines 27 and 33.
|
||||||
#CUSTOMDIR1="$HOME/.local/share/nautilus/scripts"
|
#CUSTOMDIR1="$HOME/.local/share/nautilus/scripts"
|
||||||
CUSTOMDIR1=""
|
CUSTOMDIR1=""
|
||||||
CUSTOMDIR2=""
|
CUSTOMDIR2=""
|
||||||
|
@ -24,9 +24,18 @@ nnnpluginsdir="$HOME/.config/nnn/plugins"
|
||||||
|
|
||||||
# Preview with bat if installed
|
# Preview with bat if installed
|
||||||
if [ -z "$(command -v bat)" ]; then
|
if [ -z "$(command -v bat)" ]; then
|
||||||
plugin=$(find "$nnnpluginsdir" "$CUSTOMDIR1" "$CUSTOMDIR2" -maxdepth 3 -perm -111 -type f 2>/dev/null | fzf --ansi --preview 'cat {}' --preview-window right:66% --delimiter / --with-nth -1 --bind="?:toggle-preview")
|
plugin=$(find "$nnnpluginsdir" "$CUSTOMDIR1" "$CUSTOMDIR2" \
|
||||||
|
-maxdepth 3 -perm -111 -type f 2>/dev/null | fzf --ansi --preview \
|
||||||
|
"cat {}" \
|
||||||
|
--preview-window right:66%:wrap --delimiter / --with-nth -1 \
|
||||||
|
--bind="?:toggle-preview")
|
||||||
else
|
else
|
||||||
plugin=$(find "$nnnpluginsdir" "$CUSTOMDIR1" "$CUSTOMDIR2" -maxdepth 3 -perm -111 -type f 2>/dev/null | fzf --ansi --preview 'bat --color=always --style=grid {}' --preview-window right:66% --delimiter / --with-nth -1 --bind="?:toggle-preview")
|
plugin=$(find "$nnnpluginsdir" "$CUSTOMDIR1" "$CUSTOMDIR2" \
|
||||||
|
-maxdepth 3 -perm -111 -type f 2>/dev/null | fzf --ansi --preview \
|
||||||
|
"bat --terminal-width='$(tput cols)' --decorations=always --color=always \
|
||||||
|
--style='${BAT_STYLE:-header,numbers}' {}" \
|
||||||
|
--preview-window right:66% --delimiter / --with-nth -1 \
|
||||||
|
--bind="?:toggle-preview")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try running the script on the hovered file, and abort if no plugin was selected (ESC or ^C pressed),
|
# Try running the script on the hovered file, and abort if no plugin was selected (ESC or ^C pressed),
|
||||||
|
|
|
@ -97,7 +97,8 @@ startpreview() {
|
||||||
|
|
||||||
tmux split-window -e "NNN_FIFO=$NNN_FIFO" -e "PREVIEW_MODE=1" -e "PAGER=$PAGER" \
|
tmux split-window -e "NNN_FIFO=$NNN_FIFO" -e "PREVIEW_MODE=1" -e "PAGER=$PAGER" \
|
||||||
-e "USE_SCOPE=$USE_SCOPE" -e "SPLIT=$SPLIT" -e "USE_PISTOL=$USE_PISTOL" \
|
-e "USE_SCOPE=$USE_SCOPE" -e "SPLIT=$SPLIT" -e "USE_PISTOL=$USE_PISTOL" \
|
||||||
-e "PAGERPID=$PAGERPID" -e "IMGPID=$IMGPID" -e "CURSEL=$CURSEL" -e "TMPDIR=$TMPDIR" \
|
-e "BAT_STYLE=${BAT_STYLE:-numbers}" -e "PAGERPID=$PAGERPID" \
|
||||||
|
-e "IMGPID=$IMGPID" -e "CURSEL=$CURSEL" -e "TMPDIR=$TMPDIR" \
|
||||||
-e "FIFO_UEBERZUG=$FIFO_UEBERZUG" -e "QLPATH=$QLPATH" -d"$SPLIT" "$0" "$1"
|
-e "FIFO_UEBERZUG=$FIFO_UEBERZUG" -e "QLPATH=$QLPATH" -d"$SPLIT" "$0" "$1"
|
||||||
elif [ "$TERMINAL" = "kitty" ]; then
|
elif [ "$TERMINAL" = "kitty" ]; then
|
||||||
# Setting the layout for the new window. It will be restored after the
|
# Setting the layout for the new window. It will be restored after the
|
||||||
|
@ -111,8 +112,8 @@ startpreview() {
|
||||||
--cwd "$PWD" --env "PATH=$PATH" --env "NNN_FIFO=$NNN_FIFO" \
|
--cwd "$PWD" --env "PATH=$PATH" --env "NNN_FIFO=$NNN_FIFO" \
|
||||||
--env "PREVIEW_MODE=1" --env "PAGER=$PAGER" --env "TMPDIR=$TMPDIR" \
|
--env "PREVIEW_MODE=1" --env "PAGER=$PAGER" --env "TMPDIR=$TMPDIR" \
|
||||||
--env "USE_SCOPE=$USE_SCOPE" --env "SPLIT=$SPLIT" --env "TERMINAL=$TERMINAL"\
|
--env "USE_SCOPE=$USE_SCOPE" --env "SPLIT=$SPLIT" --env "TERMINAL=$TERMINAL"\
|
||||||
--env "USE_PISTOL=$USE_PISTOL" --env "PAGERPID=$PAGERPID" \
|
--env "USE_PISTOL=$USE_PISTOL" --env "BAT_STYLE=${BAT_STYLE:-numbers}" \
|
||||||
--env "IMGPID=$IMGPID" --env "FIFO_UEBERZUG=$FIFO_UEBERZUG" \
|
--env "PAGERPID=$PAGERPID" --env "GIFPID=$GIFPID" --env "FIFO_UEBERZUG=$FIFO_UEBERZUG" \
|
||||||
--env "CURSEL=$CURSEL" --location "${SPLIT}split" "$0" "$1" >/dev/null
|
--env "CURSEL=$CURSEL" --location "${SPLIT}split" "$0" "$1" >/dev/null
|
||||||
elif [ -n "$2" ]; then
|
elif [ -n "$2" ]; then
|
||||||
QUICKLOOK=1 QLPATH="$2" PREVIEW_MODE=1 "$0" "$1" >/dev/null &
|
QUICKLOOK=1 QLPATH="$2" PREVIEW_MODE=1 "$0" "$1" >/dev/null &
|
||||||
|
@ -156,7 +157,8 @@ fifo_pager() {
|
||||||
exec > "$tmpfifopath"
|
exec > "$tmpfifopath"
|
||||||
if [ "$cmd" = "pager" ]; then
|
if [ "$cmd" = "pager" ]; then
|
||||||
if exists bat; then
|
if exists bat; then
|
||||||
bat --terminal-width="$(tput cols)" --paging=never --decorations=always --color=always "$@" 2>/dev/null &
|
bat --terminal-width="$(tput cols)" --decorations=always --color=always \
|
||||||
|
--paging=never --style="${BAT_STYLE:-numbers}" "$@" 2>/dev/null &
|
||||||
else
|
else
|
||||||
$PAGER "$@" &
|
$PAGER "$@" &
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -113,7 +113,8 @@ startpreview() {
|
||||||
|
|
||||||
tmux split-window -e "NNN_FIFO=$NNN_FIFO" -e "PREVIEW_MODE=1" -e "PAGER=$PAGER" \
|
tmux split-window -e "NNN_FIFO=$NNN_FIFO" -e "PREVIEW_MODE=1" -e "PAGER=$PAGER" \
|
||||||
-e "USE_SCOPE=$USE_SCOPE" -e "SPLIT=$SPLIT" -e "USE_PISTOL=$USE_PISTOL" \
|
-e "USE_SCOPE=$USE_SCOPE" -e "SPLIT=$SPLIT" -e "USE_PISTOL=$USE_PISTOL" \
|
||||||
-e "PAGERPID=$PAGERPID" -e "IMGPID=$IMGPID" -e "CURSEL=$CURSEL" -e "TMPDIR=$TMPDIR" \
|
-e "BAT_STYLE=${BAT_STYLE:-numbers}" -e "PAGERPID=$PAGERPID" \
|
||||||
|
-e "IMGPID=$IMGPID" -e "CURSEL=$CURSEL" -e "TMPDIR=$TMPDIR" \
|
||||||
-e "ICONLOOKUP=$ICONLOOKUP" -e "NNN_PREVIEWDIR=$NNN_PREVIEWDIR" \
|
-e "ICONLOOKUP=$ICONLOOKUP" -e "NNN_PREVIEWDIR=$NNN_PREVIEWDIR" \
|
||||||
-e "NNN_PREVIEWWIDTH=$NNN_PREVIEWWIDTH" -e "NNN_PREVIEWHEIGHT=$NNN_PREVIEWHEIGHT" \
|
-e "NNN_PREVIEWWIDTH=$NNN_PREVIEWWIDTH" -e "NNN_PREVIEWHEIGHT=$NNN_PREVIEWHEIGHT" \
|
||||||
-e "FIFO_UEBERZUG=$FIFO_UEBERZUG" -e "QLPATH=$2" -d"$SPLIT" "$0" "$1"
|
-e "FIFO_UEBERZUG=$FIFO_UEBERZUG" -e "QLPATH=$2" -d"$SPLIT" "$0" "$1"
|
||||||
|
@ -129,8 +130,8 @@ startpreview() {
|
||||||
--cwd "$PWD" --env "PATH=$PATH" --env "NNN_FIFO=$NNN_FIFO" \
|
--cwd "$PWD" --env "PATH=$PATH" --env "NNN_FIFO=$NNN_FIFO" \
|
||||||
--env "PREVIEW_MODE=1" --env "PAGER=$PAGER" --env "TMPDIR=$TMPDIR" \
|
--env "PREVIEW_MODE=1" --env "PAGER=$PAGER" --env "TMPDIR=$TMPDIR" \
|
||||||
--env "USE_SCOPE=$USE_SCOPE" --env "SPLIT=$SPLIT" --env "TERMINAL=$TERMINAL"\
|
--env "USE_SCOPE=$USE_SCOPE" --env "SPLIT=$SPLIT" --env "TERMINAL=$TERMINAL"\
|
||||||
--env "USE_PISTOL=$USE_PISTOL" --env "PAGERPID=$PAGERPID" \
|
--env "USE_PISTOL=$USE_PISTOL" --env "BAT_STYLE=${BAT_STYLE:-numbers}" \
|
||||||
--env "IMGPID=$IMGPID" --env "FIFO_UEBERZUG=$FIFO_UEBERZUG" \
|
--env "PAGERPID=$PAGERPID" --env "GIFPID=$GIFPID" --env "FIFO_UEBERZUG=$FIFO_UEBERZUG" \
|
||||||
--env "ICONLOOKUP=$ICONLOOKUP" --env "NNN_PREVIEWDIR=$NNN_PREVIEWDIR" \
|
--env "ICONLOOKUP=$ICONLOOKUP" --env "NNN_PREVIEWDIR=$NNN_PREVIEWDIR" \
|
||||||
--env "NNN_PREVIEWWIDTH=$NNN_PREVIEWWIDTH" --env "NNN_PREVIEWHEIGHT=$NNN_PREVIEWHEIGHT" \
|
--env "NNN_PREVIEWWIDTH=$NNN_PREVIEWWIDTH" --env "NNN_PREVIEWHEIGHT=$NNN_PREVIEWHEIGHT" \
|
||||||
--env "CURSEL=$CURSEL" --location "${SPLIT}split" "$0" "$1" >/dev/null
|
--env "CURSEL=$CURSEL" --location "${SPLIT}split" "$0" "$1" >/dev/null
|
||||||
|
@ -176,7 +177,8 @@ fifo_pager() {
|
||||||
exec > "$tmpfifopath"
|
exec > "$tmpfifopath"
|
||||||
if [ "$cmd" = "pager" ]; then
|
if [ "$cmd" = "pager" ]; then
|
||||||
if exists bat; then
|
if exists bat; then
|
||||||
bat --terminal-width="$(tput cols)" --paging=never --decorations=always --color=always "$@" 2>/dev/null &
|
bat --terminal-width="$(tput cols)" --decorations=always --color=always \
|
||||||
|
--paging=never --style="${BAT_STYLE:-numbers}" "$@" 2>/dev/null &
|
||||||
else
|
else
|
||||||
$PAGER "$@" &
|
$PAGER "$@" &
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue