From 15970781b5e3eafaac2fd7ed3730079fd4cfb451 Mon Sep 17 00:00:00 2001 From: cashmere Date: Sun, 26 Apr 2026 21:20:59 +0200 Subject: fix(justfile): test-sixel-tmux skips nesting when already inside tmux Running `just test-sixel-tmux' from a tmux pane previously printed `sessions should be nested with care, unset $TMUX to force' and exited with code 1. Switch the recipe to a shebang body that branches at runtime: when `$TMUX' is already set, run emacs directly in the current pane (the test condition is already satisfied -- we're inside tmux); otherwise spawn a fresh `tmux new-session' wrapper as before. --- justfile | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'justfile') diff --git a/justfile b/justfile index 008f4ad..306290e 100644 --- a/justfile +++ b/justfile @@ -145,15 +145,28 @@ test-sixel-image encoder="": --eval "(kitty-graphics-mode 1)" \ tests/test-image.png -# Open test-image.png inside `tmux new-session', sixel backend forced -# (run on a sixel-capable outer terminal, requires tmux >= 3.4) +# Open test-image.png inside tmux with sixel backend forced. +# Outer terminal must be sixel-capable (foot, Konsole, mintty, mlterm, WezTerm). +# Requires tmux >= 3.4 built with --enable-sixel. +# When already inside tmux, runs emacs directly (no nesting). test-sixel-tmux encoder="": - @echo ">> Outer terminal must be sixel-capable (foot, Konsole, mintty, ...)." - @echo ">> tmux >= 3.4 with --enable-sixel required." - tmux new-session -As kgfx-sixel-test "TERM={{TERM_}} {{EMACS}} -nw -Q -l {{SRC}} \ - --eval '(setq kitty-gfx-debug t kitty-gfx-preferred-protocol (quote sixel))' \ - --eval '(when (> (length \"{{encoder}}\") 0) (setq kitty-gfx-sixel-encoder-program \"{{encoder}}\"))' \ - --eval '(kitty-graphics-mode 1)' tests/test-image.png" + #!/usr/bin/env bash + set -eu + if [ -n "${TMUX:-}" ]; then + echo ">> Already inside tmux -- running emacs directly in this pane." + exec env TERM={{TERM_}} {{EMACS}} -nw -Q -l {{SRC}} \ + --eval '(setq kitty-gfx-debug t kitty-gfx-preferred-protocol (quote sixel))' \ + --eval '(when (> (length "{{encoder}}") 0) (setq kitty-gfx-sixel-encoder-program "{{encoder}}"))' \ + --eval '(kitty-graphics-mode 1)' \ + tests/test-image.png + else + echo ">> Outer terminal must be sixel-capable; spawning fresh tmux session." + exec tmux new-session -As kgfx-sixel-test \ + "TERM={{TERM_}} {{EMACS}} -nw -Q -l {{SRC}} \ + --eval '(setq kitty-gfx-debug t kitty-gfx-preferred-protocol (quote sixel))' \ + --eval '(when (> (length \"{{encoder}}\") 0) (setq kitty-gfx-sixel-encoder-program \"{{encoder}}\"))' \ + --eval '(kitty-graphics-mode 1)' tests/test-image.png" + fi # --- Logs ------------------------------------------------------------------- -- cgit v1.3.1