Wednesday, September 16, 2026

WezTerm: One Terminal, CJK and tmux

Dotori Bluetooth PPT Remote - Your phone as a PC slideshow remote

A free app I built myself. Give it a try.

Developing on Windows, the terminal is always in the way. ls a directory with Korean file names in it and the columns go out of line. Start a full-screen tool such as lazygit or btop and the borders step sideways. You end up with four windows and alt+tab. To use tmux you have to go inside WSL. That leaves the PowerShell and .NET builds you need outside tmux.

I settled all of this with WezTerm. One configuration file (.wezterm.lua) in your home folder is the whole setup. That file behaves identically on Windows, macOS and Linux. Below is the configuration I actually use, broken into pieces. Copy them in order and you will have my environment.

Installing and the configuration file

On Windows, download the installer from the WezTerm releases page or use winget.

winget install wez.wezterm

Create the configuration file in your home folder as .wezterm.lua. That is usually C:\Users\<name>\.wezterm.lua. The beginning and end of the file always look like this.

local wezterm = require("wezterm")
local act = wezterm.action
local config = wezterm.config_builder()

-- configuration goes in here

return config

It takes effect the moment you save. There is no need to restart the terminal. Edit the config and save, and the colours, font and keys of the open window change. That alone makes tinkering with the configuration feel different.

Korean works without a single line of configuration

These two lines are the only font settings in my config. There is no Korean font specified anywhere.

config.font = wezterm.font("JetBrains Mono", { weight = "Light" })
config.font_size = 13

JetBrains Mono has no Korean glyphs. Korean still renders fine. WezTerm walks the font list per character. When a glyph is missing it falls back to a system font. You can check it yourself.

wezterm ls-fonts --text "한글 테스트 ABC"

This is the output on my machine.

한  cells=2  x_adv=17  Malgun Gothic  C:\WINDOWS\FONTS\MALGUN.TTF
글  cells=2  x_adv=17  Malgun Gothic  C:\WINDOWS\FONTS\MALGUN.TTF
A   cells=1  x_adv=10  JetBrains Mono

The number that matters is cells. Korean counts as two columns, Latin as one. Get that wrong and table borders shift and progress bars bend. The cursor no longer sits where the text does. Most of what CJK users suffer in a terminal comes from that single number. WezTerm computes it according to the character width standard.

Korean input needs no switch either. Change input mode and type: the syllable being composed appears right at the cursor. It never shows up somewhere else or disappears before it is finished.

You only have to set the shell's character set to UTF-8. I use Git Bash and give it these environment variables.

LANG=ko_KR.UTF-8
LC_ALL=ko_KR.UTF-8

The main point: tmux behaviour without tmux

People use tmux mostly for one thing: splitting the screen to watch several things at once. WezTerm has that in the terminal itself. There is no tmux to install.

First pick the prefix key, the equivalent of tmux's Ctrl+B. Mine is Ctrl+U.

config.leader = { key = "u", mods = "CTRL", timeout_milliseconds = 2000 }

Now press Ctrl+U, let go, and press a letter within two seconds. This is my layout.

Splitting

  • Ctrl+U then w : split left/right (Width)
  • Ctrl+U then v : split top/bottom (Vertical)

Moving between panes

  • Ctrl+U then h : to the left pane
  • Ctrl+U then j : to the pane below
  • Ctrl+U then k : to the pane above
  • Ctrl+U then l : to the right pane

Resizing

  • Ctrl+U then an arrow key : grow by five cells in that direction

Tabs

  • Ctrl+U then c : new tab (Create)
  • Ctrl+U then n : next tab, b : previous tab
  • Ctrl+U then 0-9 : straight to that tab

Other

  • Ctrl+U then u : new window
  • Ctrl+U then d : detach this pane into its own window (Detach)
  • Ctrl+U then x : close this pane (it asks first)

The movement keys are h/j/k/l to match vim, so your hands stay put. Splits are w/v. Remembering left/right as Width and top/bottom as Vertical keeps them straight.

The configuration looks like this. It is long but regular, so copy the block and change the letters.

local keys = {}

local function leader(key, action)
    table.insert(keys, { mods = "LEADER", key = key, action = action })
end

leader("w", act.SplitHorizontal({ domain = "CurrentPaneDomain" }))
leader("v", act.SplitVertical({ domain = "CurrentPaneDomain" }))
leader("h", act.ActivatePaneDirection("Left"))
leader("j", act.ActivatePaneDirection("Down"))
leader("k", act.ActivatePaneDirection("Up"))
leader("l", act.ActivatePaneDirection("Right"))
leader("LeftArrow",  act.AdjustPaneSize({ "Left", 5 }))
leader("RightArrow", act.AdjustPaneSize({ "Right", 5 }))
leader("UpArrow",    act.AdjustPaneSize({ "Up", 5 }))
leader("DownArrow",  act.AdjustPaneSize({ "Down", 5 }))
leader("c", act.SpawnTab("CurrentPaneDomain"))
leader("u", act.SpawnWindow)
leader("n", act.ActivateTabRelative(1))
leader("b", act.ActivateTabRelative(-1))
leader("x", act.CloseCurrentPane({ confirm = true }))

-- detach the current pane into its own window
leader("d", wezterm.action_callback(function(_, pane)
    pane:move_to_new_window()
end))

-- Ctrl+U then a digit jumps to that tab
for i = 0, 9 do
    table.insert(keys, { mods = "LEADER", key = tostring(i), action = act.ActivateTab(i) })
end

config.keys = keys

To number tabs from zero, add the first line below. The leftmost key in the number row becomes the first tab, which is easier on the hands. I also moved the tab bar to the bottom.

config.tab_and_split_indices_are_zero_based = true
config.tab_bar_at_bottom = true
config.use_fancy_tab_bar = false

The screen tells you whether the prefix is armed

There is a common annoyance with tmux. You do not know whether you pressed Ctrl+B, so a stray character lands in the terminal. I made a wave appear in the status bar while the prefix is live.

wezterm.on("update-status", function(window, _)
    local prefix = ""
    if window:leader_is_active() then
        prefix = " " .. utf8.char(0x1f30a)   -- wave emoji
    end
    window:set_left_status(wezterm.format({ { Text = prefix } }))
end)

Press Ctrl+U and a wave appears at the bottom left. Press the next key only while you can see it. It is a small device that cuts typos sharply.

Where it is clearly better than tmux

Each pane can run a different shell. Git Bash on the left, PowerShell at the top right, WSL Ubuntu at the bottom right. tmux is confined to the Linux world it runs inside. WezTerm's splitting is a terminal feature. Windows programs and Linux shells can share one window. For anyone developing on Windows that difference is decisive.

Copy and paste work with the OS clipboard directly. There is no copy mode to enter, no range to mark, no separate clipboard bridge to bolt on. Drag with the mouse and it is on the clipboard.

config.selection_word_boundary = " \t\n{}[]()\"'`"

config.mouse_bindings = {
    -- left click selects only (so links are not opened by accident)
    {
        event = { Up = { streak = 1, button = "Left" } },
        mods = "NONE",
        action = act.CompleteSelection("ClipboardAndPrimarySelection"),
    },
    -- open links with Ctrl+click
    {
        event = { Up = { streak = 1, button = "Left" } },
        mods = "CTRL",
        action = act.OpenLinkAtMouseCursor,
    },
}

For pasting I left both the terminal convention (Ctrl+Shift+V) and the general one (Ctrl+V) open. Either habit works. These entries go into the keys table built earlier.

table.insert(keys, { key = "c", mods = "CTRL|SHIFT", action = act.CopyTo("Clipboard") })
table.insert(keys, { key = "v", mods = "CTRL|SHIFT", action = act.PasteFrom("Clipboard") })
table.insert(keys, { key = "v", mods = "CTRL",       action = act.PasteFrom("Clipboard") })
table.insert(keys, { key = "Insert", mods = "SHIFT", action = act.PasteFrom("Clipboard") })

Scrolling is just scrolling. Turn the wheel and it scrolls. I keep thirty thousand lines.

config.scrollback_lines = 30000
config.enable_scroll_bar = true

When a long build log has made the window heavy, I clear the scrollback.

table.insert(keys, {
    key = "k", mods = "CTRL|SHIFT",
    action = act.ClearScrollback("ScrollbackAndViewport"),
})

I also made Ctrl plus the mouse wheel change the font size. Being able to write that behaviour in the config file says a lot about WezTerm's character. The configuration is Lua, a programming language. You write behaviour rather than fill in prepared values.

local min_font_size, max_font_size = 8, 24

local function zoom(delta)
    return wezterm.action_callback(function(window)
        local overrides = window:get_config_overrides() or {}
        local size = overrides.font_size or config.font_size
        overrides.font_size = math.max(min_font_size, math.min(size + delta, max_font_size))
        window:set_config_overrides(overrides)
    end)
end

-- these go inside the mouse_bindings table above
{ event = { Down = { streak = 1, button = { WheelUp = 1 } } },   mods = "CTRL", action = zoom(1) },
{ event = { Down = { streak = 1, button = { WheelDown = 1 } } }, mods = "CTRL", action = zoom(-1) },

Picking one of six shells from a menu

Alt+L brings up a shell menu, and the one you pick opens in a new tab. I have six registered.

config.default_prog = { "C:\Program Files\Git\bin\bash.exe" }

config.launch_menu = {
    { label = "Git Bash",       args = { "C:\Program Files\Git\bin\bash.exe" } },
    { label = "Clean Git Bash", args = { "C:\Program Files\Git\bin\bash.exe", "--noprofile", "--norc", "-i" } },
    { label = "PowerShell",     args = { "powershell.exe" } },
    { label = "Command Prompt", args = { "cmd.exe" } },
    { label = "WSL Ubuntu",     args = { "wsl.exe", "-d", "Ubuntu" } },
}

table.insert(keys, { key = "l", mods = "ALT", action = act.ShowLauncher })

The second entry, Clean Git Bash, is worth a look. --noprofile --norc means start the shell skipping every startup script. When something behaves oddly, it answers "is this my .bashrc?" in thirty seconds. You write the command and its arguments as an array, so you can keep as many variants as you like. I have one that starts with every environment variable cleared, too.

I also changed the new-tab button (+) so that it shows this menu instead of opening an empty tab.

wezterm.on("new-tab-button-click", function(window, pane, button, default_action)
    window:perform_action(act.ShowLauncher, pane)
    return false   -- cancel the default action (creating an empty tab)
end)

What I use most: driving the terminal from the command line

WezTerm has a wezterm cli command that manipulates the open windows, tabs and panes from outside.

wezterm cli list                                  list the open windows, tabs and panes
wezterm cli split-pane --right                    split to the right and print the new pane id
wezterm cli send-text --pane-id 3 "make build"    type text into pane 3
wezterm cli get-text  --pane-id 3                 read what is visible in pane 3
wezterm cli zoom-pane --pane-id 3                 zoom that pane
wezterm cli kill-pane --pane-id 3                 close that pane

This matters because the terminal becomes something a script can drive. split-pane prints the id of the pane it created, so you can capture it in a variable and keep going.

ID=$(wezterm cli split-pane --right)
wezterm cli send-text --pane-id "$ID" --no-paste "make build"
wezterm cli send-text --pane-id "$ID" --no-paste $'\r'
# a moment later
wezterm cli get-text --pane-id "$ID" | tail -20

Two pieces of practical knowledge here. First, you need --no-paste. Without it the text arrives as a paste. Modern shells do not run pasted content immediately; they leave it sitting on the input line.

Second, send Enter separately from the command. Sending CR ($'\r') as its own call is more reliable than appending a newline to the command string. Not knowing these two can leave you stuck on "the text went in but nothing ran".

The reading side has an option too. get-text gives you what is currently on screen by default. A negative --start-line reaches back into the scrollback. I use it when I need a whole build log.

wezterm cli get-text --pane-id "$ID" --start-line -2000

I use this to run several AI agents on one screen. Open a new pane and start another agent in it. Send instructions with send-text and read the reply with get-text. The next instruction is written from that.

I set two AIs to argue over a design. Or I split the roles so one writes code and the other only verifies it. The human's job is to watch from the side.

Terminals that allow this are not common. Plenty of them split the screen. Few open a channel that lets a program create the split from outside. Fewer still let it type in and read the result back.

There is a way out when it freezes

The terminal draws text on the GPU, which makes it very fast. In exchange, a bad graphics driver match can freeze the window. WezTerm lets you choose the rendering back end.

config.front_end = "WebGpu"                        -- this is my default
config.webgpu_power_preference = "HighPerformance"
-- if it freezes, switch to "OpenGL", and to "Software" if that still fails

Software draws on the CPU, so it is a little slower but comes up in any environment. Knowing there is a guaranteed escape one config line away is a real comfort in practice. You can tune the refresh load as well.

config.max_fps = 120
config.animation_fps = 60
config.status_update_interval = 1000

I also turned off the confirmation when closing a window, since I open and close them constantly.

config.exit_behavior = "Close"
config.window_close_confirmation = "NeverPrompt"

Where tmux is still better

To be fair about it: one of tmux's core features is that the session stays alive. Connect to a remote server, start something and drop the connection. It is still running when you attach again. WezTerm's screen splitting does not have that property. Close the window and the work inside it ends.

So for starting a job that takes hours on a server over SSH, tmux on that server is the right tool. And it does not conflict with WezTerm: connect to the server with WezTerm and use tmux inside it. The point of this post is not to abandon tmux. You no longer need to install tmux and go into WSL just to split the screen on your own PC.

Wrapping up

In short:

  • Korean renders with the right width calculation. No Korean font in the config; the system font fills in
  • Making Ctrl+U the prefix reproduces tmux's splitting, movement, resizing and tabs almost exactly
  • Panes can mix Git Bash, PowerShell and WSL
  • The clipboard, the mouse and scrolling behave the way you expect
  • wezterm cli lets a script drive the terminal itself
  • The config is Lua, so you write behaviour directly, and it applies the moment you save
  • The same single file behaves identically on Windows, macOS and Linux

That last line matters more than it looks. I keep .wezterm.lua in a dotfiles repository. Setting up a new PC means installing with winget and copying that one file into my home folder. Years of hand-tuned key layout, colours and shell list come back in five minutes.

Program: WezTerm (wezterm.org)

Configuration file: a single .wezterm.lua in your home folder

Related articles

Explorer First, or the Terminal?

Dotori Currency Converter - 30 currencies at official ECB rates

A free app I built myself. Give it a try.

There are two routes to handling files on Windows: open Explorer, or open a terminal. Which one is better has no answer. The time actually leaks somewhere else — when a single job makes you cross between the two. I settled it by removing the cost of crossing, and here are the three bridges I use.

They are good at different things

There are situations where Explorer is clearly faster. Skimming a folder you are opening for the first time. Hunting for a file whose name you cannot remember. Clicking a photo or a PDF to check it. For jobs that end with looking and pointing, there is no reason to build a command.

The situations where the terminal wins have a different character. Doing the same job a second time. Applying a condition, such as only this extension or only files changed since yesterday. Needing a record of what you did.

So the test comes down to one question. Will I do this again? For a one-off, Explorer is faster. For something you will repeat, it is better to give it a name in the terminal and keep it. Work done in Explorer leaves no trace. Doing the same thing next month means clicking your way through it again.

The trouble comes when one job straddles both sides. Picking yesterday's files out of twenty logs and attaching them to an email is like that. Picking is overwhelmingly faster in the terminal. Getting them into the mail window needs the clipboard or the mouse. At that point people reopen Explorer and start looking for the files by eye. The three things below remove that round trip.

Crossing from the terminal to Explorer

The first is opening the folder you are in as an Explorer window. One line does it.

alias exp='start "" "$(pwd)"'

No more digging back down to a folder in Explorer that you already reached with cd.

The second is picking files in the terminal and putting the result on the clipboard as files. It is the files themselves rather than text. Ctrl+V in Explorer or a mail composer pastes them directly.

fcp() {
  local w=()
    for f in "$@"; do [ -e "$f" ] && w+=("'$(cygpath -aw "$f")'"); done
      [ ${#w[@]} -eq 0 ] && { echo "fcp: no files" >&2; return 1; }
        local list; list=$(IFS=,; echo "${w[*]}")
          powershell -NoProfile -Command "Set-Clipboard -Path @($list)"
          }

The key part is cygpath -aw, which converts a Git Bash path into a Windows path. PowerShell does not understand /tmp/a.txt. Check what actually ended up on the clipboard and you see this.

$ fcp a.txt b.txt
$ # what went on the clipboard
C:\Users\dualk\AppData\Local\Temp\src\a.txt
C:\Users\dualk\AppData\Local\Temp\src\b.txt

Now the earlier example is one line. fcp $(ls -t *.log | head -5) puts the five most recent logs on the clipboard. You paste them in the mail window.

Crossing from Explorer to the terminal

The other direction has two parts: bringing a folder over, and bringing files over.

For folders the context menu is shortest. Right-click a folder in Explorer and entries such as Open WezTerm here appear. They open a terminal in that folder. The Git Bash one is registered automatically when you install Git. These are the commands in my registry.

Directory\shell\git_shell
  "C:\Program Files\Git\git-bash.exe" "--cd=%1"
  
  Directory\shell\Open WezTerm here
    "C:\Program Files\WezTerm\wezterm-gui.exe" start --cwd "%V\"

There is one thing worth knowing here. Right-clicking a folder and right-clicking empty space inside a folder read different places. The first is Directory\shell, the second Directory\Background\shell. A program registered in only one of them appears in the menu sometimes and not others. On Windows 11 the context menu is shortened. Use "Show more options" or Shift+F10 to see the full menu.

Bringing files over is fpaste. Press Ctrl+C in Explorer, call it in the terminal, and the files are copied into the current folder.

fpaste() {
  powershell -NoProfile -Command "Add-Type -A System.Windows.Forms; [Windows.Forms.Clipboard]::GetFileDropList() | ForEach-Object { \$_ }" |
      tr -d "\r" | while IFS= read -r f; do
            [ -n "$f" ] && cp -r "$(cygpath -u "$f")" "${1:-.}" && echo "pasted: $(basename "$f")"
                done
                }

GetFileDropList pulls the file list out of the clipboard. cygpath -u turns the Windows paths back into Git Bash paths. File names with spaces come across intact.

$ fpaste
pasted: a b.txt
pasted: c.txt

Give fcp and fpaste a short alias each and your hands remember those first. I use ccp and ccv, named straight after Ctrl+C and Ctrl+V.

Summary

DirectionCommandWhat it does
Terminal → ExplorerexpOpens the current folder in an Explorer window
Terminal → anywherefcp file…Puts the chosen files on the clipboard
Explorer → terminalRight-click a folderOpen WezTerm here opens a terminal in that folder
Explorer → terminalfpasteBrings files you copied with Ctrl+C into the current folder

Explorer and the terminal are not competitors. One-off work is faster in Explorer. Work you will repeat is better named and kept in the terminal. What is left is the cost of crossing between them, and the three lines above nearly remove it.

If you add only one of the three, make it exp. It is one line, and from the day you add it you stop navigating back to folders in Explorer.

From Alias to Function to Script

Dotori Bluetooth Keyboard - Your phone as a keyboard for PC and TV

A free app I built myself. Give it a try.

Type the same command twice in a terminal and you make an alias. Use aliases for a while and two things turn up that they cannot do. You cannot put an if statement in one, and inside a script they do not work at all. There are two other ways to give a command a name — functions and script files. Here is the test for choosing among the three, starting from what an alias actually is.

An alias replaces the first word of a command

An alias replaces the first word of a command with another string you decided in advance. The shell swaps the text as it reads the command line. The rest of the command runs as it always would. Creating one is a single line and removing it is a single unalias. It is simple, and it does three jobs.

First, it cuts keystrokes. A command you type twenty times a day becomes two characters.

alias gs='git status'
alias la='ls -a'

Second, you no longer have to remember options. This is more useful than the keystrokes. -w ignores lines that changed only in whitespace. Putting it inside a name is more reliable than recalling it each time.

alias gdu='git --no-pager diff -w'
alias rgrep='grep -rni'

Third, it changes a tool's default behaviour, by redefining it under the same name.

alias lsd='lsd --group-dirs=first'

It calls itself, so it looks like it should recurse forever, and it does not. The text swap happens once, on the first word only. So lsd becomes a command that always lists folders first.

$ lsd
zdir
a.txt
b.txt

When you need the original behaviour, put a backslash in front. \lsd is the unmodified command. To see what is currently bound, use type lsd; for the full list, run alias with no arguments.

If you need an if statement, or a change of directory, use a function

Swapping text is all it does, so there are things it cannot do. You cannot put in an if statement, and you cannot insert an argument in the middle of the command. That is when it becomes a function.

My gd is a function. Some of my machines have delta, which prettifies diffs, and some do not.

gd() {
    if command -v delta >/dev/null 2>&1; then
            git -c core.pager=delta diff -w "$@"
                else
                        git --no-pager diff -w "$@"
                            fi
                            }

The second case has no way around it at all. Running a script starts a separate process. That process cannot change the current directory of the shell that called it. A cd inside a script disappears with the process.

before: /tmp/cdtest
/tmp/cdtest/sub     <- pwd printed after the script's cd
after:  /tmp/cdtest <- the parent shell is unchanged

Say you browse folders in the file manager yazi and want your shell left where you stopped. That has to be a function. You take the directory yazi ended in through a temporary file and cd there in the shell itself.

yz() {
    local tmp="$(mktemp -t yazi-cwd.XXXXXX)"
        yazi "$@" --cwd-file="$tmp"
            local cwd
                if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
                        cd -- "$cwd"
                            fi
                                rm -f -- "$tmp"
                                }

Put the same code in a script file and the cd happens inside that process only. It has no effect at all.

If a program will call it rather than a person, make it a file

The last one is a slightly different story. An alias only works in a shell where a person types commands directly. Such a shell is called an interactive shell. I confirmed it with a two-line script.

$ cat t.sh
alias hello='echo hi'
hello

$ bash t.sh
t.sh: line 2: hello: command not found

The bash manual says so — "Aliases are not expanded when the shell is not interactive". The only exception is the expand_aliases option. Put shopt -s expand_aliases on the first line of the script and the same code works.

So commands inside a Makefile, CI jobs and commands an AI coding agent calls cannot be aliases. They are not typed by a person; they are called by a program. In those cases you make a file. Three lines of work.

mkdir -p ~/bin                      # a folder to collect scripts in
chmod +x ~/bin/git-log-file.sh      # execute permission
echo 'export PATH="$PATH:$HOME/bin"' >> ~/.bashrc

From then on you call it by name, git-log-file.sh, from any folder. It is the same command whether you type it, a Makefile runs it, or an agent calls it.

The merge script from the post on merging worktrees is a real example of something kept as a file. I type it by hand and an agent also calls it, so it had to be a file.

You do not have to pick only one of the three. Make the file, then point an alias at it and the typing gets shorter again.

alias glf='~/bin/git-log-file.sh'

Summary

MethodUse it forWhere it lives
aliasJobs where replacing the first word is enoughA shell you type in
functionJobs that need an if statement or a change of directoryA shell you type in
script fileJobs called by scripts, Makefiles, CI or agentsA file on your PATH

An alias replaces the first word and nothing more. That is why it is easy to make, and why its limits are clear. When you need an if statement or a change of directory, move to a function. When a program rather than a person will call it, make it a file.

What you can do right now is type alias with no arguments and read the list. Some of them you wished had an if statement, or wanted to call from a script. Move those to a function or a file first.

Merging Many Worktrees Into One Line

Dotori Bluetooth Numpad - Your phone as a 17-key number pad

A free app I built myself. Give it a try.

Once you have more than three worktrees open, the next problem arrives. How do you put them back together? I seat one worker in each folder and merge everything into one line with a single script at the end. What matters is not the merge strategy but whether a failure lands you back where you started.

The number of folders is the number of parallel jobs

In the first post a worktree was a tool for removing the cost of switching branches. The property that each folder is an independent build tree has a second use. Several folders can run at the same time without interfering with each other. Two processes building the same repository collide over output paths and break. With worktrees those paths are different to begin with.

So I use folders as work slots. A documentation worker sits in the docs folder and a feature worker in feature-login. Each runs builds and tests in their own place. The human only reviews, from the master folder.

It suits running several AI agents in parallel especially well. The agents never fight over file locks. When one breaks the build, the other slots are fine.

What was opened in parallel is collected in one line, not in merge commits

Merge five branches into master one at a time and the graph turns into a bundle of diamonds. Read that history later and you cannot tell which change was verified on top of which. So I go the other way. The branches go in order of descent. Each is appended onto the new tip of the previous one with rebase --onto. When that is done, every branch is fast-forwarded to the final tip.

My --gw1 flag does this. The plan it prints before running looks like this.

merge plan — linearize 3 worktrees onto 'master', then ff-all:
  master               pull --ff-only: already up to date
    master               (base, tip ce5b697f)
      docs                 ff-advance chain to be09cdb1
        feature/login        rebase --onto <docs> ce5b697f
          then fast-forward every branch (incl. master) to the final tip
            then push master → origin/master (fast-forward, never forced)

The result is one straight line with no merge commits. Every worktree points at the same commit, so a build in any folder gives the same result.

* 8494e3f add login page
* be09cdb write docs
* ce5b697 init

The value of the automation comes from atomicity

A rebase chain that hits a conflict halfway stops with half of the history rewritten. That state is the biggest risk in the whole thing. So on failure every branch is put back to the sha it had on entry. I built two conflicting branches and actually ran it. All that was left was the line below and exit 1. The shas of all three branches were identical to what they had been.

git-worktree: rebase conflict on 'feature/login' (onto previous tip) — rolled back
to entry state (except the origin ff of 'master'). resolve 'feature/login' manually,
then retry.

Because the rollback is guaranteed, I do not guess at the outcome with a dry run. I just run it and see. A three-way conflict only shows up when a rebase is actually attempted, so this is the faster route. How each stage handles failure is decided in advance.

StageOn failure
Syncing the default branch with origin (first)Touch nothing, abort everything
Rebase chain / ff alignmentRoll every branch back to its entry state
Final push to originNo rollback. The linearization stands

The sync goes first because stacking on a stale base means diverging again at push time. At the other end, rolling back a failed push would throw away a linear result you worked for. A network or permission problem should not cost you that. So there the tool leaves git's own refusal message and a retry command. Failure is signalled through the exit code alone. Fix the cause, run it again, and only the push is retried.

Summary

Worktree folders are parallel work slots, and the price of adding slots is paid at the final merge. Pay that price as one rebase chain rather than a bundle of merge commits. The history stays readable, and every folder starts again from the same commit. Whether a job can be handed to automation is decided by atomicity on failure, not by speed.

Next time you run three or more branches at once, write the script that will combine them first. Put the rollback in that script.

Related articles

git worktree: Branches as Folders

Dotori Bluetooth Numpad - Your phone as a 17-key number pad

A free app I built myself. Give it a try.

You run git stash every time you move to another branch. Then you sit through a full rebuild when you come back. This post removes that waste. A worktree turns a branch switch into a folder change. Three commands get you started, and three traps are worth knowing before you do.

The cost of switching is in the build output, not the source

git switch swaps tracked files and nothing else. The expensive things are what sits beside them: obj/, bin/, node_modules/. When the whole source tree changes, the incremental build is invalidated. Moving to another branch to check one line then costs you minutes. Work in progress has to be pushed into a stash, and popping it afterwards brings conflicts.

Cloning the repository a second time solves that, but it duplicates the history and the objects too. A worktree attaches several working folders to one repository. Objects and refs are shared, and only the checkout is separate. It has been built in since Git 2.5 on 29 July 2015, with add, list and prune. There is nothing to install.

ApproachHistoryBuild cacheParallel work
stash + switchOne copyInvalidated on every switchNo
Extra cloneDuplicated per folderKeptYes
worktreeSharedKeptYes

Add more clones and you have to run fetch in each folder. A branch created in one of them is invisible in the others. A worktree shares refs, so a branch you created next door shows up right where you are.

Three commands to start

git worktree add ../hotfix -b hotfix   # a new branch and a folder in one go
git worktree list                      # which branch is attached to which folder
git worktree remove ../hotfix          # clean up the folder (the branch stays)

The first line creates the sibling folder ../hotfix and checks a new branch out into it. Your original folder is untouched. The build output and the file you were editing stay exactly as they were. To pull out an existing branch, drop -b: git worktree add ../review feature/login. list prints one line per folder with its sha and branch.

.../demo    dfd2991 [main]
.../hotfix  dfd2991 [hotfix]

There are only three traps

  1. The same branch cannot live in two folders. Check out a branch that is already attached and Git refuses with fatal: 'main' is already used by worktree at .... Branches and folders are one to one.
  2. remove deletes the folder only. The branch stays behind, so delete it separately with git branch -d. The other way round, if you deleted the folder in Explorer, the registration is left behind and git worktree prune clears it.
  3. A linked worktree's .git is a file, not a folder. It holds one line: gitdir: .../worktrees/hotfix. Scripts and tools that assume a .git directory and build paths from it break here.

The bare layout takes away the main folder's privilege

The default arrangement is "main repository plus attached folders". That gives the main one a special position. Delete it and the rest are orphaned. You also have to remember which folder in the list is the original. To put every folder on equal footing, hide a bare repository and give each branch one folder.

proj/
  .bare/          # the bare repository (no working files here)
    .git            # a file holding one line, "gitdir: ./.bare"
      master/         # folder = branch
        feature-login/

Fetch with git clone --bare <url> .bare and create the .git pointer file. Then produce the first folder with git worktree add master. From then on branch names and folder names are one to one. ls alone shows everything you have open.

Summary

The real cost of a branch switch is not swapping source but invalidating build output. A worktree separates the folders and takes that cost to zero. add, list and remove are all you need. Remember that a branch and a folder are one to one, and that .git is a file, and nothing goes wrong.

Run git worktree add ../hotfix -b hotfix once in the repository you have open right now. The next post uses these folders as parallel work slots and merges them all in one line at the end.

Related articles

Catching Disk Hogs With WinDirStat

Dotori Bluetooth Mouse - Your phone as a Bluetooth mouse for PC

A free app I built myself. Give it a try.

When the bar for the C: drive turns red, most people empty the Recycle Bin first. A few hundred megabytes come back, and a few days later it is red again. The files actually eating the space are in neither the Recycle Bin nor the Disk Cleanup list. WinDirStat is a free program that sweeps a whole drive and draws file sizes as rectangle areas. A big file is a big rectangle, so you spot the culprit by eye.

Why emptying the Recycle Bin does not give the space back

The Recycle Bin holds only files you deleted. What fills the drive is files you never deleted and do not remember creating. Disk Cleanup and Storage Sense are the same. They check a predetermined list and leave everything else alone. That list is temporary files, update leftovers and thumbnails.

What eats the space is mostly outside that list. Virtual machine disk images. Caches that developer tools downloaded. Game update files. Previous versions stacked up by a backup program.

They are all legitimate files, so cleanup tools do not see them as candidates for deletion. On my own C: drive, a single virtual disk file created by Claude Desktop was taking 7.5GB. Emptying the Recycle Bin a hundred times would never surface it.

Install it with one winget line

Windows 10 and 11 include winget out of the box. Open a terminal or a command prompt and one line is all it takes.

winget install WinDirStat.WinDirStat

The current stable version is 2.8.0, released on 2 August 2026. There is no homepage to hunt for an installer on, and no bundled adware to untick during setup. It is open source under the GPL, free for individuals and companies alike. Give it administrator rights when you run it and it sweeps other user accounts' folders too.

Area is file size

WinDirStat 2.8.0 after scanning a C: drive. In the treemap below, one rectangle is one file and its area is the file size

The coloured rectangles filling the bottom half of the window are the treemap. The whole picture is one drive, and one rectangle is one file. Area is directly proportional to file size, and colour means file extension. So there are no numbers to read and compare. Whatever looks big is the file eating the most space. (The screenshot is from a Korean-language install; the layout is the same in English.)

The magenta vertical bar with the white outline is the 7.51GB virtual disk file mentioned above. Click a rectangle and that file is selected in the folder list at the top. Pick a folder in the list and you see what part of the treemap it occupies. The list on the right is a total per extension. "Is it videos or installers" is answered immediately as well.

Finding it does not mean deleting it

Not every big file is rubbish. You have to separate what can go from what must not be touched.

What shows up large in the treemapWhat to do
Installers and old ISOs in DownloadsSafe to delete
Virtual machine or Docker images you no longer useDelete from that program
Caches from games or video editorsClear from that program's settings
pagefile.sys, hiberfil.sysDo not delete; resize them in Windows settings
Files inside Windows and Program FilesLeave alone

Big files created by an app are safer cleared from that app than deleted directly. The program then never fails looking for a file that is gone. Once you have checked a file, right-click it in the WinDirStat list. Open it in Explorer or delete it there.

Summary

The Recycle Bin and Disk Cleanup sweep only a fixed list. They miss the files that really eat space. WinDirStat draws file sizes as rectangle areas, so you see which file is the culprit at a glance. Installing it is one line: winget install WinDirStat.WinDirStat.

Open a terminal now, install it and scan the C: drive once. When the scan finishes, click the largest rectangle. The name of the file that has stolen your space for months appears at the bottom.

Install Windows Programs From One Line

Dotori Bluetooth Numpad - Your phone as a 17-key number pad

A free app I built myself. Give it a try.

I typed winget upgrade once on this machine. Forty-two programs came back with updates pending. Wireshark, yt-dlp, tools whose names I had forgotten, one after another. Finding each homepage and downloading each installer would have taken half a day.

Linux has apt and the Mac has brew. Windows has tools that do the same job, and there are three of them. This post covers what separates winget, Chocolatey and Scoop, and which one to pick. The conclusion first: start with winget and fill the gaps with the other two.

winget is already on your machine

winget is Microsoft's official tool. Windows 11 ships with it, and recent Windows 10 gets it bundled with App Installer from the Store. That means there is nothing to install. Open a terminal, type the following, and if you get a version you are ready.

winget --version

Three things are enough to use it. Find by name, install by id, upgrade everything at once.

winget search git
winget install Git.Git
winget upgrade --all

The results of winget search include an id column. It is safer to install by that id than by name. That stops a similarly named but unrelated package from being picked up.

Chocolatey and Scoop fill the places winget leaves empty

Chocolatey is the elder, around since 2011. Its community repository holds close to ten thousand packages. Each package carries its own install script, so it handles installation options in fine detail. The default install location is C:\ProgramData\chocolatey and it needs administrator rights. The open-source edition is Apache 2.0 licensed, so it is free to use at work. A separate paid business edition adds more features.

Scoop has the opposite character. It unpacks programs inside your user folder only (C:\Users\<user>\scoop). It needs no administrator rights and does not touch the registry. For anyone who cannot get administrator rights on a work machine, that is decisive.

Packages are grouped into "buckets". When something is not in the default bucket you add another, as in scoop bucket add extras. The bucket sizes I measured on my machine were 1,637 in main, 2,372 in extras and 336 in java.

One table separates the three

ItemwingetChocolateyScoop
Separate installNot neededNeededNeeded
Administrator rightsUsually neededNeededNot needed
Install locationSame as a normal installC:\ProgramData\chocolateyUser folder
What it does wellGeneral programsInstall-option control, company rolloutsDeveloper tools, machines without rights

Scoop installs in two lines from an ordinary, non-administrator PowerShell window. The first line permits script execution.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression

The payoff comes when you set up a new machine

For installing one program, a command and a mouse are about the same. The gap opens when you get a new computer. winget exports the list of what is installed now to a file. That file restores all of it on the new machine.

winget export -o apps.json
winget import -i apps.json --accept-package-agreements --accept-source-agreements

The exported apps.json is just a text file. Open it in Notepad and delete lines you do not want. The two options on the end skip the agreement prompts during installation. Without them the run stops at each program waiting for confirmation.

Summary

Windows installs and updates programs from the command line too. winget is already there, so there is nothing to prepare. Add Scoop when you have no administrator rights. Add Chocolatey when you need fine control over installation options. The three do not conflict, so keep them on one machine together.

Open a terminal now and type winget upgrade. It takes a few seconds to find out how many updates have been piling up.

A Makefile Is a Command List

Dotori LG TV Remote - Your phone as an LG TV remote

A free app I built myself. Give it a try.

Think of a Makefile as a tool for compiling C programs and you miss most of the places it belongs. The Makefile in my home folder has no compilation in it at all. It has things like turning UAC off, adding a firewall rule, and registering a drive-lock menu entry. What make actually does is attach a bundle of commands to one name. Building is only one use for that.

Commands unrelated to building are fine

These are the kind of targets in my Makefile.

uac-off: ## Turn UAC off (requires a reboot)
	@echo "would disable UAC"
    
    ping-open: ## Add a firewall rule allowing ICMP
    	@echo "would add firewall rule"

These are commands I use maybe once a month. I cannot keep them in my head. Search for them again and the options differ from what I used last time. Bundle a command you found once under a name and next time it is just make uac-off.

You could write a shell script instead, and there is a reason to use make. A Makefile only applies in its own folder. An alias applies to the whole machine, so you have to watch out for name collisions. A script means remembering where you put it. You can keep one Makefile per project and standardise on make build everywhere. Step into a folder, type make, and you see what can be done in that project.

As the earlier post on aliases noted, commands inside a Makefile run in a shell called by a program. It is not a shell a person types in. So aliases cannot be used here; you write the command out in full or call a script file.

The target list becomes the help text

This is where the value comes from. Add ## description at the end of a target line and you can scrape that list into help output. One block at the top of the Makefile.

.DEFAULT_GOAL := help
.PHONY: help

help: ## List the available targets
	@grep -hE '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
    		| awk 'BEGIN{FS=":.*?## "}{printf "  \033[36m%-14s\033[0m %s\n", $$1, $$2}'

Thanks to .DEFAULT_GOAL := help, typing make with no arguments prints the help.

$ make
  help           List the available targets
    uac-off        Turn UAC off (requires a reboot)
      ping-open      Add a firewall rule allowing ICMP

grep picks out lines of the form name: … ## description and awk splits them on ## and aligns them. So adding a target grows the help by itself. There is no separate document to copy descriptions into, and no document to go stale. A target without ## does not appear in the list, so you can hide internal ones.

Three things that catch you on Windows

First, the indentation of a command line must be a tab. Use spaces and it stops like this.

Mbad:9: *** missing separator (did you mean TAB instead of 8 spaces?).  Stop.

Make does tell you clearly. If your editor converts tabs to spaces you will keep hitting it. Make an exception for that folder. The same thing happens when you copy a Makefile from the web.

Second, non-ASCII text in an echo on a command line comes out mangled. The encoding is mismatched on the path make takes to the shell. My own Makefile is in Korean, and this is what a Korean echo produced.

$ make ko
?쒓? 異쒕젰 ?쒕룄

The same Korean in a ## description is fine. In the real help output, "Turn UAC off" is written in Korean in my file and printed correctly. That is because grep and awk read and emit the file bytes directly. In short, non-ASCII is fine in the description comments and should stay out of echo bodies.

Third, write $ as $$. That is what $$1, $$2 and .*$$ are doing in the help block above. With a single $, make swallows it as its own variable and awk receives an empty value.

Summary

ItemRule
IndentationTabs only. Spaces give missing separator
Non-ASCIIFine in ## description, keep echo bodies ASCII
$Doubled, as $$
Default target.DEFAULT_GOAL := help so plain make prints the list

A Makefile is a list of what can be done in that folder. Put in the commands you use once a month. The ones that took a while to find, and the ones you have to explain to someone else.

Add the help block above to the project you are working on now. Turn one command you recently looked up into a target. The value shows immediately.

Your Terminal Setup Is the Agent's Hands

Dotori Bluetooth PPT Remote - Your phone as a PC slideshow remote

A free app I built myself. Give it a try.

You may be doing this several times a day. Open a file to ask an AI about the code, select all, paste it into a chat box. Then carry the answer back into the editor. There is a point where tools that need that round trip and tools that do not part ways. It is whether the result can stay in the conversation or has to end up in a file. Pick the side where it ends up in a file and the commands you built earlier get used as they are.

The split is about where the result ends up

A chat window knows only what I pasted. It cannot see what is in the file next door or whether the build passes. Its answer stays inside the conversation. That suits talking through a design, asking about a concept, or having one snippet looked over. There is little to paste and all you need is the conclusion.

An agent running in the terminal has a different character. Claude Code is one: it reads and edits files directly, runs builds and tests, and works with git. It digs through the repository and finds things without me pasting them.

Chat windowTerminal agent
What it knowsWhat was pastedThe whole repository
ResultA conversationFiles and commits
How it is checkedA person copies it out and runs itIt builds and tests itself
What it suitsDesign discussion, concept questionsChanges that will be committed

The test is one line. If the result can end in the conversation, use the chat window. If it has to stay in the repository, use the terminal. Doing conversation-sized work in the terminal is overkill. The other way round, file-sized work in a chat window keeps a person shuttling text back and forth.

The agent uses the commands I already made

Once you pick the terminal side, something changes. The agent calls my own commands. Set up make build and it verifies its work with that. Keep a script as a file and it calls that file.

One thing gets in the way here. It cannot call an alias. The shell that comes up when an agent runs a command is not a shell a person types in. Aliases are not loaded. That is the behaviour confirmed in the earlier post about aliases. So commands you share with an agent go in files or Makefile targets, not aliases.

Once they are, one more thing becomes possible. Write those commands in the project's CLAUDE.md and the agent uses them.

## Build and verification
- Build: `make build`
- Test: `make test`
- Do not report a change as done if it has not been verified with these two.

With those three lines the agent runs the build itself after editing code. It fixes the code again when the build breaks. Without them you get "I fixed it" and do the checking yourself. The target list from the post on using a Makefile as a command list pays off right here.

Split accounts and settings by folder

One practical addition. Want different accounts for work and personal projects, or simply separate settings? One environment variable does it. The official documentation states the purpose. Give it this variable and it stores "settings, session history, and plugins" in that folder.

Point it at a separate folder and the settings and session history go in there. The entry points are aliases.

alias cck='CLAUDE_CONFIG_DIR="$HOME/claude/kwak" claude'
alias cch='CLAUDE_CONFIG_DIR="$HOME/claude/help" claude'

These are commands I type by hand, so an alias is right. What the previous section said to write down as files were the commands an agent calls. The same test applies, pointing the other way.

Summary

A chat window and a terminal agent part ways over where the result ends up. Split the work that can end in a conversation from the work that has to end in a file.

Once you decide on the terminal side, everything you built so far becomes the agent's hands. The bridges between Explorer and the terminal. Your functions and script files. Your Makefile targets. What you made for your own convenience is used by the agent too. The alias is the one exception.

One thing you can do now is write your build and test commands into CLAUDE.md, one line each. That line is the difference between "I fixed it" and "I fixed it and checked".

Real Symlinks in Git Bash on Windows

Dotori Bluetooth Numpad - Your phone as a 17-key number pad

A free app I built myself. Give it a try.

You have probably run ln -s in Git Bash and ended up with a copy of the file rather than a link. Bring dotfiles that worked on Linux over to Windows and every link turns into a text file. Same cause. Four settings fix it. This post covers those four steps and the symptoms you get when one of them is missing.

A symbolic link is a signpost holding a target path

A symbolic link is not a copy of a file. It is a special file holding a path string that says "the real file is over there". You keep the original in one place. Several locations refer to it as if it were the same file. Edit the original and everything reached through the link sees the change at once.

Git stores symbolic links as they are. Where an ordinary file is recorded in mode 100644, a link goes in as mode 120000. Its content is a single target path string.

$ git ls-files -s
120000 c9c61fe1fb4b3b... 0	alias.txt
100644 10622902e19e73... 0	real.txt

The problem is on the Windows side. Windows has symbolic links too, but creating one requires the SeCreateSymbolicLinkPrivilege right. By default only administrators have it. Everything below exists to work around that constraint.

All four steps have to line up before a link is created

  1. When installing Git, tick Enable symbolic links on the last screen.
  2. Run Git Bash as administrator.
  3. Put export MSYS=winsymlinks:nativestrict in the shell environment.
  4. Add symlinks = true under [core] in ~/.gitconfig.

Steps 3 and 4 are two commands.

echo 'export MSYS=winsymlinks:nativestrict' >> ~/.bashrc
git config --global core.symlinks true

The MSYS variable is the key one. Its default is deepcopy, so when it cannot create a link it quietly copies the file instead. nativestrict creates native links only and raises an error when the privilege is missing. Because it does not hide the failure, you see the cause immediately. Open a new terminal and check like this.

$ ln -s real.txt alias.txt
$ ls -l alias.txt
lrwxrwxrwx 1 dualk 197609 8  Aug 27 16:59 alias.txt -> real.txt

A leading l and an arrow mean it worked. -rw-r--r-- means you got a copy.

Change the properties of the real exe, not the shortcut

Right-clicking and running as administrator every time is a chore. Follow the Git Bash shortcut back to the actual executable. Give that file permanent administrator rights.

  1. Trace the Git Bash shortcut to the original .exe, right-click it and choose Properties.
  2. On the Compatibility tab, tick Run this program as an administrator.

If keeping an administrator shell open all the time bothers you, there is an alternative. Developer Mode lets an ordinary user account create symbolic links. It has been there since Windows 10 Creators Update (1703). Enable it under Settings > Privacy & security > For developers, reboot, and step 3 alone is enough.

Miss a setting and links quietly become text files

The worst case is the one that produces no error. Clone a repository with core.symlinks off and the link is not created. In its place you get an ordinary file whose content is the path string.

StateStart of ls -lResult of cat alias.txt
Working linklrwxrwxrwx ... -> real.txtThe content of the original file
Broken link-rw-r--r-- (8 bytes)real.txt (a path string)

What makes it worse is that git status comes back clean. Git does not see this as a change, so it can be committed without anyone noticing. The core.symlinks=false value from the clone is baked into that repository's .git/config. Turn the global setting on later and the local setting still wins. That one repository stays broken.

git config --local --get core.symlinks    # if this prints false, that is the cause
git config --local --unset core.symlinks  # remove the local setting
git checkout -- .                          # lay the working tree out again

Summary

A symbolic link is a file holding a target path. On Windows, creating one needs a separate privilege. All four have to line up. Install option, administrator rights, MSYS=winsymlinks:nativestrict, core.symlinks=true. Miss any one of them and you get a copy instead of an error, with git status staying quiet about it.

Open Git Bash now and run echo $MSYS and git config --get core.symlinks. If both come back empty, start with the two commands above.

WezTerm 3: Sessions That Outlive Windows

Dotori Roman Numerals - Arabic and Roman numerals, both ways

A free app I built myself. Give it a try.

At the end of part 1 I wrote that "WezTerm's splits do not have this property. Close the window and the work inside it ends." That was only true of the default configuration. One line of config and the work inside keeps running when you close the window. The split layout comes back with it. I am writing down exactly what I confirmed on my own PC.

Close the window and the build keeps going

Start a command in a terminal window and closing the window kills the command. The window and the program are one thing.

The two can be separated. A separate server running in the background holds the program. The window becomes a pane of glass you look through. Take the glass away and the inside keeps running. Put it back and even the output that accumulated meanwhile is there.

It is easiest to picture with a situation. You split the screen three ways. dotnet build runs on the left, the log is at the top right, and a shell sits at the bottom right. The build takes about ten minutes. Close the window here and

  • the build is not interrupted and carries on,
  • reopening later brings those three panes back, sizes included, and
  • the output from before you closed is still there.

It is the same in three other cases. The terminal hangs, you edit the config and need a restart, or you close the window by mistake. Attach a new window and you are back where you were.

In part 1 I wrote that tmux is confined to the Linux world it runs inside. The server holding the work here is a Windows program, so that limit does not apply. Run Git Bash in one pane or a .NET build under PowerShell in another and both survive the same way.

One line of config and two shortcuts

Add one line to ~/.wezterm.lua that defines a session. mux is a name I chose, so use whatever you like.

config.unix_domains = { { name = "mux" } }

That line alone changes nothing. WezTerm still opens as an ordinary window, and whether you enter the session is decided each time. So give it one shortcut in and one out. The leader helper from part 1 is used as is.

leader("a", act.AttachDomain("mux"))                -- attach to the session
leader("e", act.DetachDomain("CurrentPaneDomain"))  -- detach from the session

You do not have to start the server yourself; it comes up on the first attach. If the session is empty it starts with a single pane. If a session is already in use it restores that layout.

The order for closing and reviving

  1. Save the config above. It takes effect the moment you save.
  2. Attach with Ctrl+U then a. The first time it starts with one pane.
  3. Split the screen and start the build as usual. The Ctrl+U then w, v from part 1 work unchanged.
  4. Detach with Ctrl+U then e. Simply closing the window gives the same result.
  5. Press Ctrl+U then a again. The layout you set up comes back.

Here is what I confirmed. With the screen split three ways I closed the window and attached again. The size of each pane was identical to the character. The lines printed before closing were still there. The server process stayed up the whole time no window existed.

It is normal that closing the window in step 4 looks the same as pressing e. If the window holds nothing but session panes, detaching the session leaves nothing in that window.

Two things to watch. What holds the work is a server process running on your PC. It disappears when you shut down or restart the machine. Closing a window and turning off the computer are not the same thing. Closing the window does not end the session. To really stop the work, close each pane.

Summary

Separate the window from the program and a build carries on after you close the window. The split layout comes back too. The config is one line and getting in and out is two shortcuts. One of the points where I said tmux was still ahead in part 1 disappears with this.

Add the line and press Ctrl+U then a. Splitting the screen, detaching and coming back takes five minutes.

Related articles

WezTerm 2: Twenty Leader Shortcuts

Dotori Bluetooth Keyboard - Your phone as a keyboard for PC and TV

A free app I built myself. Give it a try.

In part 1 I made Ctrl+U the prefix key and put splits, movement and tabs behind it. Use it for a while and the next problem arrives. Past twenty keys, what your hands remember and what the config file says drift apart. This post puts the key definitions in one table. That table produces both the real bindings and the help screen. It also covers the price of having a prefix key at all.

Put the key definitions in one table

Line up leader("w", ...) calls the way part 1 did and there is nowhere to write the description. So bundle key, description and action into one three-column entry. The bindings are generated from that list. The description becomes data rather than a comment.

local leader_bindings = {
  { "w", "Split left/right (Width)", act.SplitHorizontal({ domain = "CurrentPaneDomain" }) },
    { "v", "Split top/bottom (Vertical)", act.SplitVertical({ domain = "CurrentPaneDomain" }) },
      { "h", "Move to the left pane", act.ActivatePaneDirection("Left") },
        { "/", "Command palette", act.ActivateCommandPalette },
        }
        
        for _, b in ipairs(leader_bindings) do
          table.insert(keys, { mods = "LEADER", key = b[1], action = b[3] })
          end

Now put the same list on screen. Bind act.InputSelector to LEADER + . and the entries appear as an overlay, running the action of whichever one you pick. Add a key and the help grows with it, so the two cannot drift.

act.InputSelector({
  title = "LEADER (Ctrl+U) shortcuts",
    fuzzy = true,
      fuzzy_description = "Search shortcuts (↑↓ move · Enter run · Esc close) : ",
        choices = cheatsheet_choices,   -- { id = key, label = "key   description" }
          action = wezterm.action_callback(function(win, p, id)
              for _, b in ipairs(leader_bindings) do
                    if b[1] == id then win:perform_action(b[3], p) end
                        end
                          end),
                          })

Some keys do not fit in the table. Tab numbers are generated by a for i = 0, 9 loop, which would add ten entries. Those belong in the help as a single informational line and must be kept out of the executable set. Give them an empty id and filter that out in the callback. They show in the list, but pressing them does nothing. Pad the columns with string.format and the keys and descriptions line up vertically.

table.insert(choices, { id = "", label = string.format("%-12s%s", "0 - 9", "Tab by number (info only)") })
-- first line of the callback
if not id or id == "" then return end

Two ways the help screen caused misfires

Do not leave out fuzzy = true. The default mode of InputSelector attaches a quick-select character to each row. That character comes in order from the default alphabet field, 1234567890abc…. It has nothing to do with the shortcut printed on the screen.

In my list the fourth entry was "close pane". Press 4 to jump to tab 4 and the pane closes. The help screen was producing misfires, so I pinned it to search mode.

The second one is when choices is built. Build that list inside the key handler and every press of LEADER + . registers a new event handler through action_callback, and they pile up. The list is fixed anyway, so build it once at config load time and keep it in a variable.

For what you will not memorise, there is the command palette

You have to decide what gets a shortcut and what does not. Attach every action you use a few times a day to the leader and the list passes twenty again. I handed the rest to the command palette and kept a single LEADER + /.

The palette is a modal overlay that searches every command WezTerm knows. Typing narrows it with a fuzzy match, and what you used often floats to the top. Its default key is Ctrl+Shift+P, so it does not need to go on the leader either. Some things already exist in the defaults, such as Ctrl+Shift+Z for zooming a pane to full screen. I left those where they were.

A combination spent on the leader is lost in the shell

Once you pick a prefix key, that combination never reaches the shell. The moment you claim Ctrl+U, the Ctrl+U that deleted everything before the cursor in bash is gone. Pick your leader from combinations your hands reach for less often in the shell. Pick it at the start, because changing it later is hard.

While the leader is armed, even keys that are not bound get swallowed. The official documentation puts it the same way: they are not passed through to the terminal. That is why the ripple indicator in part 1 is not decoration. Without it, the key you press to check whether you are in the waiting state simply disappears. After two seconds the wait clears on its own.

Summary

Put key, description and action in one table and the bindings and the help read the same source. Pin InputSelector to fuzzy = true and build the list once at load time. Leave commands you rarely use to the command palette rather than the leader.

Is your key list from part 1 already past ten lines? Move those lines into a three-column table and bind LEADER + ..

Related articles