wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.44k stars 787 forks source link

update-status does not show up on right hand side #4372

Closed esn89 closed 1 year ago

esn89 commented 1 year ago

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

20230712-072601-f4abf8fd

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

update-right-status now showing up on my right hand side.

To Reproduce

No response

Configuration

-- Pull in the wezterm API
local wezterm = require('wezterm')

local config = {}
-- In newer versions of wezterm, use the config_builder which will
-- help provide clearer error messages
if wezterm.config_builder then
    config = wezterm.config_builder()
end

local color = (function()
    local COLOR = require('colors')

    local coolors = {
        COLOR.VERIDIAN,
        COLOR.PAYNE,
        COLOR.INDIGO,
        COLOR.CAROLINA,
        COLOR.FLAME,
        COLOR.JET,
        COLOR.TAUPE,
        COLOR.ECRU,
        COLOR.VIOLET,
        COLOR.VERDIGRIS,
    }

    return coolors[2]
end)()

local color_primary = color
local title_color_bg = color_primary.bg
local title_color_fg = color_primary.fg
-- right status:
wezterm.on('update-status', function(window)
    local _, stdout, _ = wezterm.run_child_process({ 'kubectl', 'config', 'current-context' })

    local bg1 = title_color_bg:lighten(0.1)
    local bg2 = title_color_bg:lighten(0.2)

    window:set_right_status(wezterm.format({
        { Background = { Color = title_color_bg } },
        { Foreground = { Color = bg1 } },
        { Text = '' },
        { Background = { Color = title_color_bg:lighten(0.1) } },
        { Foreground = { Color = title_color_fg } },
        { Text = ' ' .. 'hi' .. ' ' },
        { Foreground = { Color = bg1 } },
        { Background = { Color = bg2 } },
        { Text = '' },
        { Foreground = { Color = title_color_bg:lighten(0.4) } },
        { Foreground = { Color = title_color_fg } },
        { Text = 'asdadfadf ' .. stdout },
    }))
end)

return config

Expected Behavior

I expect to see things like a hardcoded string and my current kubernetes cluster that I have set via: kubectl config current-context

Logs

16:04:18.898 ERROR wezterm_gui::termwindow > while processing update-right-status event: callback error
stack traceback:
        [C]: in local 'poll'
        [string "?"]:5: in function 'wezterm.run_child_process'
        [string "/Users/esn89/.config/wezterm/wezterm.lua"]:35: in function <[string "/Users/evng/.config/wezterm/wezterm.lua"]:34>
caused by: No such file or directory (os error 2)
16:04:19.019 ERROR wezterm_gui::termwindow > while processing update-right-status event: callback error
stack traceback:
        [C]: in local 'poll'
        [string "?"]:5: in function 'wezterm.run_child_process'
        [string "/Users/esn89/.config/wezterm/wezterm.lua"]:35: in function <[string "/Users/evng/.config/wezterm/wezterm.lua"]:34>
caused by: No such file or directory (os error 2)

Anything else?

No response

esn89 commented 1 year ago

Weirdly enough, when I start the terminal from another terminal as foreground, I see the update-right-status show up on my wezterm. Launching it by clicking on the icon, or via App Launcher on MacOS, my right status does not show.

esn89 commented 1 year ago

I have a feeling it cannot find the binary, because it does not know about my $PATH and the associated binaries.

esn89 commented 1 year ago

I have tried this:

config.set_environment_variables = {
    PATH = os.getenv('PATH'),
}

and that did not help.

gegoune commented 1 year ago

Try replacing binary name with full path to it.

wez commented 1 year ago

The logs clearly show that your event handler is throwing an error, so it never sets the right status on the window. wezterm inherits its PATH from Finder, which does not pull in settings from your shell, so you will need to "do something" to pick up the path.

You can either:

esn89 commented 1 year ago

Great, that fixes things. Thank you.

github-actions[bot] commented 11 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.