wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

Add a way to check current config value with wezterm CLI

Open Destroy666x opened this issue 2 years ago • 5 comments

Is your feature request related to a problem? Please describe. I just lost like 10 minutes trying to set cursor_thickness option which didn't work with the block one apparently (not documented) and I was thinking it's wrong config location. Then I lost another few minutes because the 2nd setting I tried - windows_close_confirmation - apparently doesn't work either, at least on Windows (also not documented, if not a bug).

So a way to check config values would be nice to avoid such situations and not waste time on trying the config in 3 other locations.

Also because documentation doesn't list defaults for some like https://wezfurlong.org/wezterm/config/lua/config/anti_alias_custom_block_glyphs.html

Describe the solution you'd like A command like wezterm --config cursor_thickness or wezterm config cursor_thickness could tell you the current version of that option.

Describe alternatives you've considered -

Additional context Windows 10

Destroy666x avatar Sep 02 '23 23:09 Destroy666x

This would be useful . Like wezterm --config color_scheme could tell you what the current color scheme is without trying to go looking for it in the config file, especially, give that things can be set programmatically. ways:

  • one way could be to have dynamic environment variable, but I'm not sure if that's a thing. I guess a process and process-children are stuck with the environment variable they are given at process execution.
  • a 2nd way be to rerun the initialization process as a fresh wezterm was starting, but to just finally print out the config value without starting a terminal. This approach works even when wezterm is not running or providing the current terminal process. The assumption presently is that a modified config automatically results in a running wezterm reconfiguring itself. This config file instantaneous reactivity is a default feature of wezterm. But what if the auto-reload-config feature is disabled. Then one does not get the value of the dynamic config of the running process. Perhaps there is a need to know both the static value as determined by config file and the dynamic value in a running process.
  • a 3rd way would be via some term communication protocol that could query the process of the current term providing wezterm, or to a different process/terminal window running wezterm. This approach has the advantage that one can query any wezterm that may be initialized differently.

Ref:

  • https://www.reddit.com/r/wezterm/comments/1bbq6ro/i_implemented_a_theme_switcher/

hgkamath avatar Jun 18 '24 06:06 hgkamath

I would love to have this feature. It would be a big help to debug and trying new configuration and everything else we can do with this feature. Any follow up on this request?

smujaddid avatar Jul 08 '24 08:07 smujaddid

New to wezterm. I'm also immediately frustrated by this issue. The documentation doesn't list default values for all configuration options. How can I know if I want to change the value if I don't know the current value? There should at least be a way to print out the entire current configuration.

Apreche avatar Aug 12 '24 16:08 Apreche

The feature exists, it's just frustratingly not obvious for a new user to find. After combing through the docs, I figured it out.

From WezTerm CTRL-SHIFT-L gives you a "Debug Overlay". From this Lua debugger, you can enter all sorts of Lua commands to interact with WezTerm, and the one you want is window:effective_config() which will print out all the in force configuration options and their current values.

You can also store the config in a variable and test values:

> fullconfig = window:effective_config()
> fullconfig["window_close_confirmation"]
"AlwaysPrompt"

Or print the whole thing:

> fullconfig
{
    "allow_download_protocols": true,
    "allow_square_glyphs_to_overflow_width": "WhenFollowedBySpace",
    "allow_win32_input_mode": true,
    "alternate_buffer_wheel_scroll_speed": 3,
    "animation_fps": 10,
...
}

You can test if a key exists:

> fullconfig["cursor_thickness"] ~= nil
false
> fullconfig["window_close_confirmation"] ~= nil
true

It appears you can also test changes to the config on the fly for just the current session without saving to your wezterm.lua:

overrides = window:get_config_overrides() or wezterm.config_builder()
overrides.font_size = 18.0
window:set_config_overrides(overrides)

I'm a total n00b to both Lua and WezTerm, but I did read the friendly manual (which is incredible BTW). l'll leave it to Wez to weigh in whether this is the preferred way to accomplish this, or if there's something more canonical.

Edit: I'll add one more handy one for newbies - color schemes. If you want to see what colors are set, do something like this in the debugger:

> schemes = wezterm.get_builtin_color_schemes()
> schemes["tokyonight"]
{
    "ansi": [
        "#15161e",
        "#f7768e",
        "#9ece6a",
        "#e0af68",
        "#7aa2f7",
        "#bb9af7",
        "#7dcfff",
        "#a9b1d6",
    ],
...
}

Relevant Docs:

  • https://wezfurlong.org/wezterm/troubleshooting.html
  • https://wezfurlong.org/wezterm/config/lua/wezterm/config_builder.html
  • https://wezfurlong.org/wezterm/config/lua/window/effective_config.html
  • https://wezfurlong.org/wezterm/config/lua/window/set_config_overrides.html
  • https://wezfurlong.org/wezterm/config/lua/wezterm/get_builtin_color_schemes.html

mattmc3 avatar Aug 18 '24 03:08 mattmc3

@mattmc3 That is very helpful. I did not know about the Debug Overlay. Thanks for looking into that and reporting your findings!

rstefanic avatar Aug 19 '24 00:08 rstefanic