Use Windows settings editor command

This commit is contained in:
2026-07-16 23:52:08 +09:00
parent e5a4e91ec2
commit 124c99bef8

View File

@@ -147,25 +147,44 @@ config.unix_domains = {
{ name = "unix" },
}
local config_file = "/mnt/storage/wezterm.lua"
local is_windows = wezterm.target_triple:find("windows") ~= nil
local config_file = is_windows and (wezterm.home_dir .. "\\.wezterm.lua") or "/mnt/storage/wezterm.lua"
local function open_config_section(window, pane, line)
local args
if is_windows then
args = {
"powershell.exe",
"-NoLogo",
"-NoExit",
"-Command",
string.format(
'$file = %q; $line = %d; '
.. '$code = Get-Command code.cmd,code -ErrorAction SilentlyContinue | Select-Object -First 1; '
.. 'if ($code) { & $code.Source -g "${file}:${line}" } '
.. 'else { Write-Host "VS Code not found. Opening Notepad without line jump."; notepad.exe $file }',
config_file,
line
),
}
else
args = {
"sh",
"-lc",
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
),
}
end
window:perform_action(
act.SpawnCommandInNewTab({
args = {
"sh",
"-lc",
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
),
},
}),
act.SpawnCommandInNewTab({ args = args }),
pane
)
end