Tag: lua

Using resurrect.wezterm to manage Wezterm session state

One of my goals when adopting Wezterm was to replace tmux. To do that, I needed not just the ability to open additional tabs/windows and to split into panes, but also a feature I'd come to rely on heavily in the tmux ecosystem: session saving and restoration, which I accomplished with the tmux-resurrect plugin.

I tried a number of options, but was eventually pointed to resurrect.wezterm.

In this post, I'll detail how I've configured it, as well as a workflow I've developed for interacting with it that gives me (a) reasonable satisfaction that I won't lose work, and (b) additional flexibility for branching off work.

Continue reading...

Managing Wezterm Keybindings, or Merging with Lua

As I expand my Wezterm usage, I find that either (a) a third-party module will have default keybinding configuration I want to adopt, and/or (b) I want to segregate keybindings related to specific contexts into separate modules to simplify my configuration.

Keybindings are stored as a list of tables (what we call associative arrays in PHP). Simple, right?

Unlike in other languages I use, Lua doesn't have a built-in way to merge lists.

So, I wrote up a re-usable function.

Continue reading...

Escaping Regex Characters in Lua

Quick little note mainly for myself: Lua regex is different than PCRE. The big place it differs is in where you escape pattern matching characters (e.g. ., ?, +, etc.). In PCRE, you escape these with a leading backslash (e.g., \., \?, \+). However, with Lua, you use the % character: %., %?, %+.

Continue reading...