From 0ac8b7aa54dfbc1248c5921299c7f84b01f384c6 Mon Sep 17 00:00:00 2001 From: Nizamuddin Sulieman Date: Thu, 2 Feb 2023 16:14:56 +0800 Subject: [PATCH 1/3] feat(preview-tui): add `wezterm` support --- plugins/preview-tui | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/preview-tui b/plugins/preview-tui index 03239f41..9e9c3e0b 100755 --- a/plugins/preview-tui +++ b/plugins/preview-tui @@ -114,6 +114,8 @@ start_preview() { TERMINAL=tmux elif [ -n "$KITTY_LISTEN_ON" ]; then TERMINAL=kitty + elif [ -n "$WEZTERM_UNIX_SOCKET" ]; then + TERMINAL=wezterm elif [ -z "$TERMINAL" ] && [ "$TERM_PROGRAM" = "iTerm.app" ]; then TERMINAL=iterm elif [ -n "$WT_SESSION" ]; then @@ -153,6 +155,15 @@ start_preview() { --env "USE_PISTOL=$USE_PISTOL" --env "BAT_STYLE=$BAT_STYLE" \ --env "BAT_THEME=$BAT_THEME" --env "FIFOPID=$FIFOPID" \ --env "CURSEL=$CURSEL" --location "${SPLIT}split" "$0" "$1" ;; + wezterm) + if [ "$SPLIT" = "v" ]; then split="--horizontal"; else split="--bottom"; fi + PATH="$PATH" NNN_FIFO=$NNN_FIFO PREVIEW_MODE=1 CURSEL=$CURSEL TMPDIR=$TMPDIR \ + FIFOPID=$FIFOPID BAT_STYLE=$BAT_STYLE BAT_THEME=$BAT_THEME PREVIEWPID=$PREVIEWPID \ + PAGER="$PAGER" ICONLOOKUP=$ICONLOOKUP NNN_PREVIEWWIDTH=$NNN_PREVIEWWIDTH \ + USE_SCOPE=$USE_SCOPE SPLIT=$SPLIT USE_PISTOL=$USE_PISTOL \ + NNN_PREVIEWDIR=$NNN_PREVIEWDIR NNN_PREVIEWHEIGHT=$NNN_PREVIEWHEIGHT \ + FIFO_UEBERZUG=$FIFO_UEBERZUG wezterm cli split-pane --cwd "$PWD" $split "$0" "$1"; + wezterm cli activate-pane-direction Prev ;; iterm) command="$SHELL -c 'cd $PWD; \ PATH=\\\"$PATH\\\" NNN_FIFO=\\\"$NNN_FIFO\\\" PREVIEW_MODE=1 PAGER=\\\"$PAGER\\\" \ From 1ad6d30a364bf22e0101f1e65075e419bc1f8af0 Mon Sep 17 00:00:00 2001 From: Nizamuddin Sulieman Date: Thu, 2 Feb 2023 18:25:39 +0800 Subject: [PATCH 2/3] feat(preview-tui): use built in `iTerm2` image protocol if `NNN_PREVIEW_IMGPROG` is not specified. Add some notes. --- plugins/preview-tui | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/preview-tui b/plugins/preview-tui index 9e9c3e0b..0a13e14e 100755 --- a/plugins/preview-tui +++ b/plugins/preview-tui @@ -5,9 +5,10 @@ # Note: This plugin needs a "NNN_FIFO" to work. See man. # # Dependencies: -# - Supports 5 independent methods to preview with: +# - Supports 6 independent methods to preview with: # - tmux (>=3.0), or # - kitty with allow_remote_control and listen_on set in kitty.conf, or +# - wezterm (https://wezfurlong.org/wezterm), or # - QuickLook on WSL (https://github.com/QL-Win/QuickLook), or # - Windows Terminal (https://github.com/Microsoft/Terminal | https://aka.ms/terminal) with WSL, or # - $TERMINAL set to a terminal (it's xterm by default). @@ -20,7 +21,7 @@ # - man # - optional: bsdtar or atool for additional archive preview # - optional: bat for code syntax highlighting -# - optional: ueberzug, kitty terminal, viu, catimg or chafa for images +# - optional: ueberzug, kitty terminal, wezterm terminal, viu, catimg or chafa for images # - optional: convert(ImageMagick) for playing gif preview (required for kitty image previews) # - optional: ffmpegthumbnailer for video thumbnails (https://github.com/dirkvdb/ffmpegthumbnailer) # - optional: ffmpeg for audio thumbnails @@ -60,7 +61,7 @@ # will try to use a kitty terminal split. And as a final fallback, a # different terminal window will be used ($TERMINAL). # -# Tmux and kitty users can configure $SPLIT to either "h" or "v" to set a +# Tmux, wezterm and kitty users can configure $SPLIT to either "h" or "v" to set a # 'h'orizontal split or a 'v'ertical split (as in, the line that splits the # windows will be horizontal or vertical). # @@ -71,6 +72,9 @@ # With ImageMagick installed, this terminal can use the icat kitten to display images. # Refer to kitty documentation for further details. # +# Wezterm should work out of the box. If `NNN_PREVIEW_IMGPROG` is not specified it will use +# built in iTerm2 image protocol. +# # Iterm2 users are recommended to use viu to view images without getting pixelated. # # Windows Terminal users can set "Profile termination behavior" under "Profile > Advanced" settings @@ -160,7 +164,7 @@ start_preview() { PATH="$PATH" NNN_FIFO=$NNN_FIFO PREVIEW_MODE=1 CURSEL=$CURSEL TMPDIR=$TMPDIR \ FIFOPID=$FIFOPID BAT_STYLE=$BAT_STYLE BAT_THEME=$BAT_THEME PREVIEWPID=$PREVIEWPID \ PAGER="$PAGER" ICONLOOKUP=$ICONLOOKUP NNN_PREVIEWWIDTH=$NNN_PREVIEWWIDTH \ - USE_SCOPE=$USE_SCOPE SPLIT=$SPLIT USE_PISTOL=$USE_PISTOL \ + USE_SCOPE=$USE_SCOPE SPLIT=$SPLIT USE_PISTOL=$USE_PISTOL TERMINAL="$TERMINAL" \ NNN_PREVIEWDIR=$NNN_PREVIEWDIR NNN_PREVIEWHEIGHT=$NNN_PREVIEWHEIGHT \ FIFO_UEBERZUG=$FIFO_UEBERZUG wezterm cli split-pane --cwd "$PWD" $split "$0" "$1"; wezterm cli activate-pane-direction Prev ;; @@ -421,6 +425,8 @@ image_preview() { if [ "$TERMINAL" = "kitty" ]; then # Kitty terminal users can use the native image preview method kitty +kitten icat --silent --scale-up --place "$1"x"$2"@0x0 --transfer-mode=stream --stdin=no "$3" & + elif [ "$TERMINAL" = "wezterm" ] && [ -z "$NNN_PREVIEW_IMGPROG" ]; then + wezterm imgcat "$3" & elif exists ueberzug && { [ -z "$NNN_PREVIEW_IMGPROG" ] || [ "$NNN_PREVIEW_IMGPROG" = "ueberzug" ] ;}; then ueberzug_layer "$1" "$2" "$3" && return elif exists catimg && { [ -z "$NNN_PREVIEW_IMGPROG" ] || [ "$NNN_PREVIEW_IMGPROG" = "catimg" ] ;}; then From 70204a2d0fccd96264e0a6a66ab22e58f5ccafa5 Mon Sep 17 00:00:00 2001 From: Nizamuddin Sulieman Date: Sat, 4 Feb 2023 07:36:57 +0800 Subject: [PATCH 3/3] Update plugins/preview-tui use `$WEZTERM_PANE` instead, since `$WEZTERM_UNIX_SOCKET` is not set on Linux Co-authored-by: luukvbaal <31730729+luukvbaal@users.noreply.github.com> --- plugins/preview-tui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/preview-tui b/plugins/preview-tui index 0a13e14e..6d727114 100755 --- a/plugins/preview-tui +++ b/plugins/preview-tui @@ -118,7 +118,7 @@ start_preview() { TERMINAL=tmux elif [ -n "$KITTY_LISTEN_ON" ]; then TERMINAL=kitty - elif [ -n "$WEZTERM_UNIX_SOCKET" ]; then + elif [ -n "$WEZTERM_PANE" ]; then TERMINAL=wezterm elif [ -z "$TERMINAL" ] && [ "$TERM_PROGRAM" = "iTerm.app" ]; then TERMINAL=iterm