From e5a4e91ec2f5efe3080d38876ef867237d6df763 Mon Sep 17 00:00:00 2001 From: gm Date: Thu, 16 Jul 2026 23:44:17 +0900 Subject: [PATCH] Make settings editor launch robust --- wezterm.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wezterm.lua b/wezterm.lua index d1c9fa4..957c07d 100644 --- a/wezterm.lua +++ b/wezterm.lua @@ -155,7 +155,15 @@ local function open_config_section(window, pane, line) args = { "sh", "-lc", - string.format('editor="${EDITOR:-vi}"; exec "$editor" +%d %q', line, config_file), + string.format( + 'file=%q; line=%d; editor="${VISUAL:-${EDITOR:-}}"; ' + .. 'if [ -z "$editor" ]; then for candidate in nvim vim vi nano; do command -v "$candidate" >/dev/null 2>&1 && editor="$candidate" && break; done; fi; ' + .. 'if [ -z "$editor" ]; then echo "No terminal editor found. Set EDITOR or install vim/nano."; exec "${SHELL:-sh}"; fi; ' + .. '"$editor" +"$line" "$file"; status=$?; ' + .. 'if [ $status -ne 0 ]; then echo; echo "Editor exited with status $status. Press Enter to close, or type commands below."; exec "${SHELL:-sh}"; fi', + config_file, + line + ), }, }), pane