From Terminator To Wezterm

7 minute read Published: 2023-11-17

This post doesn't compare Terminator and Wezterm. This is the help I would have loved to find when starting to try Wezterm coming from Terminator.

Why this post

Coming from Terminator, you decide to try Wezterm.

You launch it.

Colors are weird, but you can keep that for later.

You try to make it full screen with a F11 and... a tilde appears, and the terminal stays small.

Then, you try several shortcuts to split the screen, nothing works.

You want to see whether the contextual menu explains the shortcuts... but no contextual menu comes to your help when you right-click.

You understand it's time to configure Wezterm, and you look in ~/.config for a file that you would modify. You find nothing...

For a newcomer, Wezterm can be a little rough.

But in fact, not a lot is missing, you just don't know it.

So here's this little blog post I would have loved to find when I was in this situation.

Before I continue, here's a link to Wezterm documentation: https://wezfurlong.org/wezterm/. It will be handy even if I do think an introduction necessary.

Create a configuration file

There's no preconfigured file, you have to create it yourself. Create it at ~/.wezterm.lua.

As the suffix implies, it's a lua program, not a structured list of entries.

Some boilerplate is needed, you just have to copy paste it once. Here's what the file looks like:

-- this paragraph is just boilerplate
local wezterm = require 'wezterm'
local config = {}
if wezterm.config_builder then
  config = wezterm.config_builder()
end

-- in between you fill the config object

return config

A very nice property of this configuration system (other than you can program it if you want) is that you don't have to relaunch Weztem when modifying the file, it's automatically reloaded on write.

In the rest of the post, I'll present some configuration entries that I think convenient coming from Terminator, then show my complete suggested file.

Change colors

First thing you'll probably want to fix is the color scheme.

I won't choose one for you, there are hundreds to choose from at https://wezfurlong.org/wezterm/colorschemes/index.html.

Here's just a half random selection of color schemes with an OK contrast and without near identical colors. You might want to copy that, select one of them by uncommenting the desired one, so that you can postpone looking at all the available schemes.

config.color_scheme = 'Idle Toes (Gogh)'
--config.color_scheme = 'Chalk'
--config.color_scheme = 'MaterialDesignColors'
--config.color_scheme = 'Mikado (terminal.sexy)'
--config.color_scheme = 'Kanagawa (Gogh)'
--config.color_scheme = 'Eqie6 (terminal.sexy)'
--config.color_scheme = 'Flatland (Gogh)'
--config.color_scheme = 'Broadcast'

Font

This part isn't really a suggestion, it's what I use and something that you can change, especially the font size.

If you do prefer ligatures, comment the first line.

config.harfbuzz_features = { 'calt=0', 'clig=0', 'liga=0' } -- disable ligatures
config.font = wezterm.font_with_fallback {
    'JetBrains Mono',
    'Fira Code',
    'DengXian',
}
config.font_size = 11.0

Window, Tabs, and Panes

Coming from Terminator, this is the most important. And you'll see that it's similar enough so that you can use Terminator and Wezterm and not lose time looking for the right shortcuts.

config.keys = {
  -- split a pane
  { key='l', mods='CTRL|SHIFT', action=wezterm.action.SplitHorizontal },
  { key='o', mods='CTRL|SHIFT', action=wezterm.action.SplitVertical },
  -- go from pane to pane
  { key='LeftArrow', mods='ALT', action=wezterm.action{ActivatePaneDirection="Left"} },
  { key='RightArrow', mods='ALT', action=wezterm.action{ActivatePaneDirection="Right"} },
  { key='UpArrow', mods='ALT', action=wezterm.action{ActivatePaneDirection="Up"} },
  { key='DownArrow', mods='ALT', action=wezterm.action{ActivatePaneDirection="Down"} },
  -- resize panes
  { key='LeftArrow', mods='CTRL|SHIFT', action=wezterm.action{AdjustPaneSize={"Left", 1}} },
  { key='RightArrow', mods='CTRL|SHIFT', action=wezterm.action{AdjustPaneSize={"Right", 1}} },
  { key='UpArrow', mods='CTRL|SHIFT', action=wezterm.action{AdjustPaneSize={"Up", 1}} },
  { key='DownArrow', mods='CTRL|SHIFT', action=wezterm.action{AdjustPaneSize={"Down", 1}} },
  -- create a tab
  { key='t', mods='CTRL|SHIFT', action=wezterm.action{SpawnTab="CurrentPaneDomain"} },
  -- go from tab to tab
  { key='PageUp', mods='CTRL', action=wezterm.action{ActivateTabRelative=-1} },
  { key='PageDown', mods='CTRL', action=wezterm.action{ActivateTabRelative=1} },
  -- move tabs
  { key='PageUp', mods='CTRL|SHIFT', action=wezterm.action{MoveTabRelative=-1} },
  { key='PageDown', mods='CTRL|SHIFT', action=wezterm.action{MoveTabRelative=1} },
  -- zoom
  { key='z', mods='CTRL|SHIFT', action=wezterm.action.TogglePaneZoomState },
  { key='F11', mods='', action=wezterm.action.ToggleFullScreen },
}

Reading the action and with the knowledge of Terminator, everything here should be obvious. And it just works.

The only thing you can't reproduce for now is moving panes with the mouse. Hopefully this should come at some point.

The default in WezTerm is to open links on click.

I don't really like that, because it departs from the behavior of most terminals, thus making using several ones harder, and it leads to many accidental openings.

So I configure WezTerm to open links on ctrl-click:

config.mouse_bindings = {
  -- Disable the default click behavior
  {
    event = { Up = { streak = 1, button = "Left"} },
    mods = "NONE",
    action = wezterm.action.DisableDefaultAssignment,
  },
  -- Ctrl-click will open the link under the mouse cursor
  {
      event = { Up = { streak = 1, button = "Left" } },
      mods = "CTRL",
      action = wezterm.action.OpenLinkAtMouseCursor,
  },
  -- Disable the Ctrl-click down event to stop programs from seeing it when a URL is clicked
  {
      event = { Down = { streak = 1, button = "Left" } },
      mods = "CTRL",
      action = wezterm.action.Nop,
  },
}

My complete configuration file

It should be a first good starting point if you're used to Terminator.

-- this paragraph is just boilerplate
local wezterm = require 'wezterm'
local config = {}
if wezterm.config_builder then
  config = wezterm.config_builder()
end

-- At the moment, wayland support is waayyyy too buggy
config.enable_wayland=false

-- This allows more interesting key combinations for programs supporting
-- the kitty keyboard protocol
config.enable_kitty_keyboard = true

--config.color_scheme = 'Chalk'
--config.color_scheme = 'MaterialDesignColors'
--config.color_scheme = 'Mikado (terminal.sexy)'
--config.color_scheme = 'Kanagawa (Gogh)'
--config.color_scheme = 'Eqie6 (terminal.sexy)'
--config.color_scheme = 'Flatland (Gogh)'
--config.color_scheme = 'Broadcast'
config.color_scheme = 'Idle Toes (Gogh)'

-- Font things
config.harfbuzz_features = { 'calt=0', 'clig=0', 'liga=0' } -- disable ligatures
config.font = wezterm.font_with_fallback {
    'JetBrains Mono',
    'Fira Code',
    'DengXian',
}
config.font_size = 11.0

config.hide_tab_bar_if_only_one_tab = true

-- Key bindings
config.keys = {
  -- prevent wezterm from intercepting some key bindings which are way too important in TUI programs
  { key='Enter', mods='ALT', action=wezterm.action.DisableDefaultAssignment },
  { key='Enter', mods='SHIFT', action=wezterm.action.DisableDefaultAssignment },
  -- split a pane
  { key='l', mods='CTRL|SHIFT', action=wezterm.action.SplitHorizontal },
  { key='o', mods='CTRL|SHIFT', action=wezterm.action.SplitVertical },
  -- go from pane to pane
  { key='LeftArrow', mods='ALT', action=wezterm.action{ActivatePaneDirection="Left"} },
  { key='RightArrow', mods='ALT', action=wezterm.action{ActivatePaneDirection="Right"} },
  { key='UpArrow', mods='ALT', action=wezterm.action{ActivatePaneDirection="Up"} },
  { key='DownArrow', mods='ALT', action=wezterm.action{ActivatePaneDirection="Down"} },
  -- resize panes
  { key='LeftArrow', mods='CTRL|SHIFT', action=wezterm.action{AdjustPaneSize={"Left", 1}} },
  { key='RightArrow', mods='CTRL|SHIFT', action=wezterm.action{AdjustPaneSize={"Right", 1}} },
  { key='UpArrow', mods='CTRL|SHIFT', action=wezterm.action{AdjustPaneSize={"Up", 1}} },
  { key='DownArrow', mods='CTRL|SHIFT', action=wezterm.action{AdjustPaneSize={"Down", 1}} },
  -- create a tab
  { key='t', mods='CTRL|SHIFT', action=wezterm.action{SpawnTab="CurrentPaneDomain"} },
  -- go from tab to tab
  { key='PageUp', mods='CTRL', action=wezterm.action{ActivateTabRelative=-1} },
  { key='PageDown', mods='CTRL', action=wezterm.action{ActivateTabRelative=1} },
  -- move tabs
  { key='PageUp', mods='CTRL|SHIFT', action=wezterm.action{MoveTabRelative=-1} },
  { key='PageDown', mods='CTRL|SHIFT', action=wezterm.action{MoveTabRelative=1} },
  -- zoom
  { key='z', mods='CTRL|SHIFT', action=wezterm.action.TogglePaneZoomState },
  { key='F11', mods='', action=wezterm.action.ToggleFullScreen },
}
--config.debug_key_events = true -- useful for debug

config.mouse_bindings = {
  -- Disable the default click behavior
  {
    event = { Up = { streak = 1, button = "Left"} },
    mods = "NONE",
    action = wezterm.action.DisableDefaultAssignment,
  },
  -- Ctrl-click will open the link under the mouse cursor
  {
      event = { Up = { streak = 1, button = "Left" } },
      mods = "CTRL",
      action = wezterm.action.OpenLinkAtMouseCursor,
  },
  -- Disable the Ctrl-click down event to stop programs from seeing it when a URL is clicked
  {
      event = { Down = { streak = 1, button = "Left" } },
      mods = "CTRL",
      action = wezterm.action.Nop,
  },
}

return config

Pay attention to the first part of my config.keys: disabling some default key bindings is something you'll probably have to do. See default key bindings.

If you think something important is missing, please come tell me at Miaou.

More than just wezterm.lua: Naming tabs

I like to give tabs a name.

In WezTerm, you can't click the tab for this as you do in Terminator.

I added this small function tt ("tab title") to my .bashrc:

function tt() {
    if [ -n "$1" ]; then
        wezterm cli set-tab-title $1
        return
    fi
    wezterm cli set-tab-title $(basename $(pwd))
}

If I type tt in one of the panes of the tab, the tab takes for name the current folder.

If I type tt hello, the tab is named "hello".

BTW, here's the list of actions you can do with wezterm cli: https://wezfurlong.org/wezterm/cli/cli/index.html.