diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-07 21:10:15 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-07 21:10:15 +0300 |
| commit | b39f233bf65c4a4b1d8d7a813b21d8477699ffae (patch) | |
| tree | 185069f91a513194545822e60276ab38a2f060c4 /internal/tmux | |
| parent | fb15616d595e0bf9f734992ceae529001e1f4677 (diff) | |
feat(tmux): add status line updates via @hexai_status; wire into CLI, LSP stats, and tmux-action
Diffstat (limited to 'internal/tmux')
| -rw-r--r-- | internal/tmux/status.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/tmux/status.go b/internal/tmux/status.go new file mode 100644 index 0000000..4e1f9e4 --- /dev/null +++ b/internal/tmux/status.go @@ -0,0 +1,28 @@ +package tmux + +import ( + "os" + "os/exec" + "strings" +) + +// Enabled reports whether tmux status updates are enabled via env (default: on). +func Enabled() bool { + v := strings.TrimSpace(os.Getenv("HEXAI_TMUX_STATUS")) + if v == "" { return true } + v = strings.ToLower(v) + return v == "1" || v == "true" || v == "yes" || v == "on" +} + +// SetUserOption sets a global tmux user option like @hexai_status to value. +func SetUserOption(key, value string) error { + if !Enabled() || !HasBinary() || !InSession() { return nil } + k := strings.TrimPrefix(strings.TrimSpace(key), "@") + if k == "" { return nil } + // Use set-option -g so it appears for all windows + return exec.Command("tmux", "set-option", "-g", "@"+k, value).Run() +} + +// SetStatus is a convenience for setting @hexai_status. +func SetStatus(value string) error { return SetUserOption("hexai_status", value) } + |
