Skip to content

Commit

Permalink
fix: tmux+wezterm plugin (#103)
Browse files Browse the repository at this point in the history
* fix: tmux+wezterm plugin

sends passthrough escape sequence to tmux, still works the same outside of tmux

* update README.md
  • Loading branch information
cockytrumpet committed Oct 20, 2023
1 parent cb73b8b commit 3506220
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ wezterm.on('user-var-changed', function(window, pane, name, value)
end)
```

If you need this functionality within tmux, you need to add the following option
to your tmux config:

```zsh
set-option -g allow-passthrough on
```

See also: https://github.com/wez/wezterm/discussions/2550

## Inspiration
Expand Down
12 changes: 10 additions & 2 deletions lua/zen-mode/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,17 @@ end
function M.wezterm(state, disable, opts)
local stdout = vim.loop.new_tty(1, false)
if disable then
stdout:write(('\x1b]1337;SetUserVar=%s=%s\b'):format('ZEN_MODE', vim.fn.system({ 'base64' }, tostring(opts.font))))
-- Requires tmux setting or no effect: set-option -g allow-passthrough on
stdout:write(
("\x1bPtmux;\x1b\x1b]1337;SetUserVar=%s=%s\b\x1b\\"):format(
"ZEN_MODE",
vim.fn.system({ "base64" }, tostring(opts.font))
)
)
else
stdout:write(('\x1b]1337;SetUserVar=%s=%s\b'):format('ZEN_MODE', vim.fn.system({ 'base64' }, '-1')))
stdout:write(
("\x1bPtmux;\x1b\x1b]1337;SetUserVar=%s=%s\b\x1b\\"):format("ZEN_MODE", vim.fn.system({ "base64" }, "-1"))
)
end
vim.cmd([[redraw]])
end
Expand Down

0 comments on commit 3506220

Please sign in to comment.