diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 486897044..78391817c 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -2,7 +2,7 @@ - [Install](installation.md) - [Features](features.markdown) - [Change Log](changelog.markdown) -- [Configuration](config/index.markdown) +- [Configuration](config/files.markdown) - [Fonts](config/fonts.markdown) - [Font Shaping](config/font-shaping.markdown) - [Misc](config/misc.markdown) diff --git a/docs/config/appearance.markdown b/docs/config/appearance.markdown index 0c052def2..d965d1622 100644 --- a/docs/config/appearance.markdown +++ b/docs/config/appearance.markdown @@ -4,8 +4,10 @@ Wezterm ships with the full set of over 200 color schemes available from [iterm2colorschemes.com](https://iterm2colorschemes.com/). You can select a color scheme with a line like this: -```toml -color_scheme = "Batman" +```lua +return { + color_scheme = "Batman", +} ``` There are literally too many schemes to reasonably list here; check out the @@ -16,7 +18,7 @@ The `color_scheme` option takes precedence over the `colors` section below. ### Defining your own colors Rather than using a color scheme, you can specify the color palette using the -`[colors]` configuration section. Note that `color_scheme` takes precedence +`colors` configuration section. Note that `color_scheme` takes precedence over this section. You can configure colors with a section like this. In addition to specifying @@ -24,51 +26,59 @@ You can configure colors with a section like this. In addition to specifying you can use `#RRGGBB` to specify a color code using the usual hex notation; eg: `#000000` is equivalent to `black`: -```toml -[colors] -# The default text color -foreground = "silver" -# The default background color -background = "black" +```lua +return { + colors = { + -- The default text color + foreground = "silver", + -- The default background color + background = "black", -# Overrides the cell background color when the current cell is occupied by the -# cursor and the cursor style is set to Block -cursor_bg = "#52ad70" -# Overrides the text color when the current cell is occupied by the cursor -cursor_fg = "black" -# Specifies the border color of the cursor when the cursor style is set to Block, -# of the color of the vertical or horizontal bar when the cursor style is set to -# Bar or Underline. -cursor_border = "#52ad70" + -- Overrides the cell background color when the current cell is occupied by the + -- cursor and the cursor style is set to Block + cursor_bg = "#52ad70", + -- Overrides the text color when the current cell is occupied by the cursor + cursor_fg = "black", + -- Specifies the border color of the cursor when the cursor style is set to Block, + -- of the color of the vertical or horizontal bar when the cursor style is set to + -- Bar or Underline. + cursor_border = "#52ad70", -# The color of the scrollbar "thumb"; the portion that represents the current viewport -scrollbar_thumb = "#222222" + -- The color of the scrollbar "thumb"; the portion that represents the current viewport + scrollbar_thumb = "#222222", -ansi = ["black", "maroon", "green", "olive", "navy", "purple", "teal", "silver"] -brights = ["grey", "red", "lime", "yellow", "blue", "fuchsia", "aqua", "white"] + ansi = {"black", "maroon", "green", "olive", "navy", "purple", "teal", "silver"}, + brights = {"grey", "red", "lime", "yellow", "blue", "fuchsia", "aqua", "white"}, + } +} ``` -### Defining a Color Scheme in your `wezterm.toml` +### Defining a Color Scheme in your `.wezterm.lua` If you'd like to keep a couple of color schemes handy in your configuration -file, rather than filling out the `[colors]` section, place it in a +file, rather than filling out the `colors` section, place it in a `color_schemes` section as shown below; you can then reference it using the `color_scheme` setting. -Color schemes names that you define in your `wezterm.toml` take precedence +Color schemes names that you define in your `wezterm.lua` take precedence over all other color schemes. -All of the settings available from the `[colors]` section are available +All of the settings available from the `colors` section are available to use in the `color_schemes` sections. -```toml -color_scheme = "Red Scheme" +```lua +return { + color_scheme = "Red Scheme", -[color_schemes."Red Scheme"] -background = "red" - -[color_schemes."Blue Scheme"] -background = "blue" + color_schemes = { + ["Red Scheme"] = { + background = "red", + } + ["Blue Scheme"] = { + background = "blue", + } + }, +} ``` ### Defining a Color Scheme in a separate file @@ -81,14 +91,15 @@ You then need to instruct wezterm where to look for your scheme files; the `color_scheme_dirs` setting specifies a list of directories to be searched: -``` -color_scheme_dirs = ["/some/path/to/my/color/schemes"] +```lua +return { + color_scheme_dirs = {"/some/path/to/my/color/schemes"}, +} ``` Color scheme names that are defined in files in your `color_scheme_dirs` list take precedence over the built-in color schemes. - ### Dynamic Color Escape Sequences Wezterm supports dynamically changing its color palette via escape sequences. @@ -111,53 +122,62 @@ $ for scheme in *.sh ; do ; echo $scheme ; \ The following options control the appearance of the tab bar: -```toml -[colors.tab_bar] -# The color of the strip that goes along the top of the window -background = "#0b0022" +```lua +return { + colors = { + tab_bar = { -# The active tab is the one that has focus in the window -[colors.tab_bar.active_tab] -# The color of the background area for the tab -bg_color = "#2b2042" -# The color of the text for the tab -fg_color = "#c0c0c0" + -- The color of the strip that goes along the top of the window + background = "#0b0022", -# Specify whether you want "Half", "Normal" or "Bold" intensity for the -# label shown for this tab. -# The default is "Normal" -intensity = "Normal" + -- The active tab is the one that has focus in the window + active_tab = { + -- The color of the background area for the tab + bg_color = "#2b2042" + -- The color of the text for the tab + fg_color = "#c0c0c0" -# Specify whether you want "None", "Single" or "Double" underline for -# label shown for this tab. -# The default is "None" -underline = "None" + -- Specify whether you want "Half", "Normal" or "Bold" intensity for the + -- label shown for this tab. + -- The default is "Normal" + intensity = "Normal" -# Specify whether you want the text to be italic (true) or not (false) -# for this tab. The default is false. -italic = false + -- Specify whether you want "None", "Single" or "Double" underline for + -- label shown for this tab. + -- The default is "None" + underline = "None" -# Specify whether you want the text to be rendered with strikethrough (true) -# or not for this tab. The default is false. -strikethrough = false + -- Specify whether you want the text to be italic (true) or not (false) + -- for this tab. The default is false. + italic = false -# Inactive tabs are the tabs that do not have focus -[colors.tab_bar.inactive_tab] -bg_color = "#1b1032" -fg_color = "#808080" + -- Specify whether you want the text to be rendered with strikethrough (true) + -- or not for this tab. The default is false. + strikethrough = false + }, -# The same options that were listed under the `active_tab` section above -# can also be used for `inactive_tab`. + -- Inactive tabs are the tabs that do not have focus + inactive_tab = { + bg_color = "#1b1032" + fg_color = "#808080" -# You can configure some alternate styling when the mouse pointer -# moves over inactive tabs -[colors.tab_bar.inactive_tab_hover] -bg_color = "#3b3052" -fg_color = "#909090" -italic = true + -- The same options that were listed under the `active_tab` section above + -- can also be used for `inactive_tab`. + }, -# The same options that were listed under the `active_tab` section above -# can also be used for `inactive_tab_hover`. + -- You can configure some alternate styling when the mouse pointer + -- moves over inactive tabs + inactive_tab_hover = { + bg_color = "#3b3052" + fg_color = "#909090" + italic = true + + -- The same options that were listed under the `active_tab` section above + -- can also be used for `inactive_tab_hover`. + } + } + } +} ``` @@ -165,14 +185,16 @@ italic = true You may add padding around the edges of the terminal cells: -``` -[window_padding] -left = 2 +```lua +return { + window_padding = { + left = 2, + -- This will become the scrollbar width if you have enabled the scrollbar! + right = 2, -# This will become the scrollbar width if you have enabled the scrollbar! -right = 2 - -top = 0 -bottom = 0 + top = 0, + bottom = 0, + } +} ``` diff --git a/docs/config/files.markdown b/docs/config/files.markdown index 019ab60f5..80e196b1e 100644 --- a/docs/config/files.markdown +++ b/docs/config/files.markdown @@ -1,22 +1,69 @@ ## Configuration Files -`wezterm` will look for a TOML configuration file in the following locations, -stopping at the first file that it finds: +`wezterm` will look for a [lua](https://www.lua.org/manual/5.3/manual.html) +configuration file in the following locations, stopping at the first file that +it finds: * If the environment variable `$WEZTERM_CONFIG_FILE` is set, it will be treated as the path to a configuration file. -* On Windows, `wezterm.toml` from the directory that contains `wezterm.exe`. +* On Windows, `wezterm.lua` from the directory that contains `wezterm.exe`. This is handy for users that want to carry their wezterm install around on a thumb drive. -* `$HOME/.config/wezterm/wezterm.toml`, -* `$HOME/.wezterm.toml` +* `$HOME/.config/wezterm/wezterm.lua`, +* `$HOME/.wezterm.lua` -`wezterm` will watch the config file that it loads; -if/when it changes, the configuration will be -automatically reloaded and the majority of options -will take effect immediately. You may also use the -`CTRL+SHIFT+R` keyboard shortcut to force the configuration to be reloaded. +`wezterm` will watch the config file that it loads; if/when it changes, the +configuration will be automatically reloaded and the majority of options will +take effect immediately. You may also use the `CTRL+SHIFT+R` keyboard shortcut +to force the configuration to be reloaded. + +To support our early adopters upgrading from an earlier release, `wezterm` can +also load TOML based configuration files; the structure supported by both lua +and TOML configuration is the same. If both lua and TOML configuration files +are present `wezterm` prefers to read the lua configuration. + +Support for loading from TOML will be removed in the nearish future; some of +the newer capabilities are not supported in TOML configuration files which makes +it a burden to continue supporting. + +## Configuration File Structure + +The `wezterm.lua` configuration file is a lua script which allows for a high +degree of flexibility. The script is expected to return a configuration +table, so a basic empty configuration file will look like this: + +```lua +return { +} +``` + +Throughout these docs you'll find configuration fragments that demonstrate +configuration and that look something like this: + +```lua +return { + color_scheme = "Batman", +} +``` + +and perhaps another one like this: + +```lua +local wezterm = require 'wezterm'; +return { + font = wezterm.font("JetBrains Mono"), +} +``` + +If you wanted to use both of these in the same file, you would merge them together +like this: + +```lua +local wezterm = require 'wezterm'; +return { + font = wezterm.font("JetBrains Mono"), + color_scheme = "Batman", +} +``` -Configuration is currently very simple and the format is considered unstable and subject -to change. The code for configuration can be found in [`src/config/mod.rs`](https://github.com/wez/wezterm/blob/master/src/config/mod.rs). diff --git a/docs/config/font-shaping.markdown b/docs/config/font-shaping.markdown index 054f7e8af..cc22c9dfe 100644 --- a/docs/config/font-shaping.markdown +++ b/docs/config/font-shaping.markdown @@ -19,8 +19,10 @@ Options of likely interest will be: If you want to disable ligatures in most fonts, then you may want to use a setting like this: -```toml -harfbuzz_features = ["calt=0", "clig=0", "liga=0"] +```lua +return { + harfbuzz_features = {"calt=0", "clig=0", "liga=0"}, +} ``` Some fonts make available extended options via stylistic sets. @@ -30,10 +32,12 @@ it lists available stylistic sets here: and you can set them in wezterm: -```toml -# Use this for a zero with a dot rather than a line through it -# when using the Fira Code font -harfbuzz_features = ["zero"] +```lua +return { + -- Use this for a zero with a dot rather than a line through it + -- when using the Fira Code font + harfbuzz_features = {"zero"} +} ``` diff --git a/docs/config/fonts.markdown b/docs/config/fonts.markdown index 80621303b..2bdf751a5 100644 --- a/docs/config/fonts.markdown +++ b/docs/config/fonts.markdown @@ -5,39 +5,48 @@ locating the fonts that you specify using the options below. In addition, if you configure the `font_dirs` option, wezterm will load fonts from that set of directories: -```toml -# This tells wezterm to look first for fonts in the directory named -# `fonts` that is found alongside your `wezterm.toml` file. -# As this option is an array, you may list multiple locations if -# you wish. -font_dirs = ["fonts"] +```lua +return { + -- This tells wezterm to look first for fonts in the directory named + -- `fonts` that is found alongside your `wezterm.toml` file. + -- As this option is an array, you may list multiple locations if + -- you wish. + font_dirs = {"fonts"}, +} ``` The following options impact how text is rendered: -```toml -# The font size, measured in points -font_size = 11 +```lua +return { + -- The font size, measured in points + font_size = 11, -# The DPI to assume, measured in dots-per-inch -# This is not automatically probed! If you experience blurry text -# or notice slight differences when comparing with other terminal -# emulators, you may wish to tune this value! -dpi = 96 + -- The DPI to assume, measured in dots-per-inch + -- This is not automatically probed! If you experience blurry text + -- or notice slight differences when comparing with other terminal + -- emulators, you may wish to tune this value! + dpi = 96, +} ``` -The baseline font is configured via the `[[font.font]]` section: +To select the font face you can use a helper function imported +from the `wezterm` module: -```toml -[[font.font]] -# The font family name. The default is "Menlo" on macOS, -# "Consolas" on Windows and "monospace" on X11 based systems. -# "Fira Code" to enjoy ligatures without buying an expensive font! -family = "Operator Mono SSm Lig Medium" -# Whether the font should be a bold variant -# bold = false -# Whether the font should be an italic variant -# italic = false +```lua +local wezterm = require 'wezterm'; + +return { + -- The font family name. The default is "Menlo" on macOS, + -- "Consolas" on Windows and "monospace" on X11 based systems. + -- You may wish to download and try either "JetBrains Mono" or + -- "Fira Code" to enjoy ligatures without buying an expensive font! + font = wezterm.font("Operator Mono SSm Lig Medium"), + + -- You can specify some parameters to influence the font selection; + -- for example, this selects a Bold, Italic font variant. + font = wezterm.font("JetBrains Mono", {bold=true, italic=true}) +} ``` If you'd like to specify fallback fonts (eg: you've got a killer @@ -45,85 +54,105 @@ monospace font, but it doesn't have glyphs for the asian script that you sometimes work with), you can specify multiple fonts that wezterm will use in the order you specify: -```toml -[[font.font]] -family = "My Preferred Font" - -# This is searched for glyphs that aren't found in the first one -[[font.font]] -family = "My second best font" - -# This is searched for glyphs that aren't found in either of -# the first two -[[font.font]] -family = "My third best font" +```lua +local wezterm = require 'wezterm'; +return { + font = wezterm.font_with_fallback({ + "My Preferred Font", + -- This is searched for glyphs that aren't found in the first one + "My second best font", + -- This is searched for glyphs that aren't found in either of + -- the first two + "My third best font", + }), +} ``` -You may specify rules that apply different font styling based on -the attributes of the text rendered in the terminal. Rules are -applied in the order that they are specified in the configuration -file, stopping with the first matching rule. +You may optionally specify rules that apply different font styling based on the +attributes of the text rendered in the terminal. Most users won't need to do +this; these rules are useful when you have some unusual fonts or mixtures of +fonts that you'd like to use. The default is to auto-generate reasonable +italic and bold styling based on the `font` configuration. -``` -# Define a rule that matches when italic text is shown -[[font_rules]] -# If specified, this rule matches when a cell's italic value exactly -# matches this. If unspecified, the attribute value is irrelevant -# with respect to matching. -italic = true +If you do specify `font_rules`, they are applied in the order that they are +specified in the configuration file, stopping with the first matching rule: -# Match based on intensity: "Bold", "Normal" and "Half" are supported -# intensity = "Normal" +```lua +local wezterm = require 'wezterm'; +return { + font_rules = { + -- Define a rule that matches when italic text is shown + { + -- If specified, this rule matches when a cell's italic value exactly + -- matches this. If unspecified, the attribute value is irrelevant + -- with respect to matching. + italic = true, -# Match based on underline: "None", "Single", and "Double" are supported -# underline = "None" + -- Match based on intensity: "Bold", "Normal" and "Half" are supported + -- intensity = "Normal", -# Match based on the blink attribute: "None", "Slow", "Rapid" -# blink = "None" + -- Match based on underline: "None", "Single", and "Double" are supported + -- underline = "None", -# Match based on reverse video -# reverse = false + -- Match based on the blink attribute: "None", "Slow", "Rapid" + -- blink = "None", -# Match based on strikethrough -# strikethrough = false + -- Match based on reverse video + -- reverse = false, -# Match based on the invisible attribute -# invisible = false + -- Match based on strikethrough + -- strikethrough = false, - # When the above attributes match, apply this font styling - [font_rules.font] - font = [{family = "Operator Mono SSm Lig Medium", italic=true}] + -- Match based on the invisible attribute + -- invisible = false, + -- When the above attributes match, apply this font styling + font = wezterm.font("Operator Mono SSm Lig Medium", {italic=true}), + } + } +} ``` -Here's an example from my configuration file: +Here's an example from my configuration file; -``` -# Select a fancy italic font for italic text -[[font_rules]] -italic = true - [font_rules.font] - font = [{family = "Operator Mono SSm Lig Medium", italic=true}] +```lua +local wezterm = require 'wezterm'; -# Similarly, a fancy bold+italic font -[[font_rules]] -italic = true -intensity = "Bold" - [font_rules.font] - font = [{family = "Operator Mono SSm Lig", italic=true, bold=true}] +-- A helper function for my fallback fonts +function font_with_fallback(name, params) + local names = {name, "Noto Color Emoji", "JetBrains Mono"} + return wezterm.font_with_fallback(names, params) +end -# Make regular bold text a different color to make it stand out even more -[[font_rules]] -intensity = "Bold" - [font_rules.font] - font = [{family = "Operator Mono SSm", bold=true}] - foreground="tomato" +return { + font = font_with_fallback("Operator Mono SSm Lig Medium"), + font_rules= { + -- Select a fancy italic font for italic text + { + italic = true, + font = font_with_fallback("Operator Mono SSm Lig Medium Italic"), + }, -# For half-intensity text, use a lighter weight font -[[font_rules]] -intensity = "Half" - [font_rules.font] - font=[{family = "Operator Mono SSm Lig Light" }] + -- Similarly, a fancy bold+italic font + { + italic = true, + intensity = "Bold", + font = font_with_fallback("Operator Mono SSm Lig Book Italic"), + }, + + -- Make regular bold text a different color to make it stand out even more + { + intensity = "Bold", + font = font_with_fallback("Operator Mono SSm Lig Bold", {foreground = "tomato"}), + }, + + -- For half-intensity text, use a lighter weight font + { + intensity = "Half", + font = font_with_fallback("Operator Mono SSm Lig Light"), + }, + }, +} ``` There are a couple of additional advanced font configuration options: @@ -141,13 +170,14 @@ There are a couple of additional advanced font configuration options: on screen. The only available implementation is `FreeType`. These options affect the appearance of the text. `Subpixel` antialiasing -is approximatley equivalent to ClearType rendering on Windows, but some +is approximateley equivalent to ClearType rendering on Windows, but some people find that it appears blurry. You may wish to try `Greyscale` in that case. ``` -font_antialias = "Subpixel" # None, Greyscale, Subpixel -font_hinting = "Full" # None, Vertical, VerticalSubpixel, Full +return { + font_antialias = "Subpixel", -- None, Greyscale, Subpixel + font_hinting = "Full", -- None, Vertical, VerticalSubpixel, Full +} ``` - diff --git a/docs/config/index.markdown b/docs/config/index.markdown deleted file mode 100644 index 1b8ae1033..000000000 --- a/docs/config/index.markdown +++ /dev/null @@ -1,21 +0,0 @@ -## Configuration Files - -`wezterm` will look for a TOML configuration file in the following locations, -stopping at the first file that it finds: - -* If the environment variable `$WEZTERM_CONFIG_FILE` is set, it will be treated as the - path to a configuration file. -* On Windows, `wezterm.toml` from the directory that contains `wezterm.exe`. - This is handy for users that want to carry their wezterm install around on a thumb drive. -* `$HOME/.config/wezterm/wezterm.toml`, -* `$HOME/.wezterm.toml` - -`wezterm` will watch the config file that it loads; -if/when it changes, the configuration will be -automatically reloaded and the majority of options -will take effect immediately. You may also use the -`CTRL+SHIFT+R` keyboard shortcut to force the configuration to be reloaded. - -Configuration is currently very simple and the format is considered unstable and subject -to change. The code for configuration can be found in [`src/config/mod.rs`](https://github.com/wez/wezterm/blob/master/src/config/mod.rs). - diff --git a/docs/config/keys.markdown b/docs/config/keys.markdown index 40ed32b2f..6e3a87288 100644 --- a/docs/config/keys.markdown +++ b/docs/config/keys.markdown @@ -49,15 +49,19 @@ The default key bindings are: | `SHIFT` | `PAGEUP` | `ScrollByPage(-1)` | | `SHIFT` | `PAGEDOWN` | `ScrollByPage(1)` | -These can be overridden using the `keys` section in your `~/.wezterm.toml` config file. +These can be overridden using the `keys` section in your `~/.wezterm.lua` config file. For example, you can disable a default assignment like this: -``` -# Turn off the default CMD-m Hide action -[[keys]] -key = "m" -mods = "CMD" -action = "Nop" +```lua +local wezterm = require 'wezterm'; + +return { + keys = { + -- Turn off the default CMD-m Hide action on macOS by making it + -- send the empty string instead of hiding the window + {key="m", mods="CMD", action=wezterm.action{SendString=""}}, + } +} ``` The `key` value can be one of the following keycode identifiers. Note that not @@ -119,36 +123,50 @@ specified via the `arg` key; see examples below. Example: -```toml -# Turn off the default CMD-m Hide action -[[keys]] -key = "m" -mods = "CMD" -action = "Nop" +```lua +local wezterm = require 'wezterm'; -# Macro for sending in some boiler plate. This types `wtf!?` each -# time CMD+SHIFT+W is pressed -[[keys]] -key = "W" -mods = "CMD|SHIFT" -action = "SendString" -arg = "wtf!?" +return { + keys = { + -- Turn off the default CMD-m Hide action + {key="m", mods="CMD", action=wezterm.action{SendString=""}}, -# CTRL+ALT+0 activates the leftmost tab -[[keys]] -key = "0" -mods = "CTRL|ALT" -action = "ActivateTab" -# the tab number -arg = "0" + -- Macro for sending in some boiler plate. This types `wtf!?` each + -- time CMD+SHIFT+W is pressed + {key="W", mods="CMD|SHIFT", action=wezterm.action{SendString="wtf!?"}}, -# CMD+y spawns a new tab in Domain 1 -[[keys]] -key = "y" -mods = "CMD" -action = "SpawnTabInDomain" -# the domain ID -arg = "1" + -- CMD-y starts `top` in a new window + {key="y", mods="CMD", action=wezterm.action{SpawnCommandInNewWindow={ + args={"top"} + }}}, + } +} ``` +Generate some key bindings based on their position: + +``` +local wezterm = require 'wezterm'; + +local mykeys = {} +for i = 1, 8 do + -- CTRL+ALT + number to activate that tab + table.insert(mykeys, { + key=tostring(i), + mods="CTRL|ALT", + action="ActivateTab", + arg=tostring(i-1) + }) + -- F1 through F8 to activate that tab + table.insert(mykeys, { + key="F" .. tostring(i), + action="ActivateTab", + arg=tostring(i-1) + }) +end + +return { + keys = mykeys, +} +``` diff --git a/docs/config/misc.markdown b/docs/config/misc.markdown index edf4c3f32..9293e997b 100644 --- a/docs/config/misc.markdown +++ b/docs/config/misc.markdown @@ -1,79 +1,80 @@ ### Misc configuration -```toml -# How many lines of scrollback you want to retain per tab -scrollback_lines = 3500 +```lua +return { + -- How many lines of scrollback you want to retain per tab + scrollback_lines = 3500, -# Enable the scrollbar. This is currently disabled by default. -# It will occupy the right window padding space. -# If right padding is set to 0 then it will be increased -# to a single cell width -enable_scroll_bar = true + -- Enable the scrollbar. This is currently disabled by default. + -- It will occupy the right window padding space. + -- If right padding is set to 0 then it will be increased + -- to a single cell width + enable_scroll_bar = true, -# If no `prog` is specified on the command line, use this -# instead of running the user's shell. -# The value is the argument array, with the 0th element being -# the executable to run. The path will be searched to locate -# this if needed. -# For example, to have `wezterm` always run `top` by default, -# you'd use this: -default_prog = ["top"] + -- If no `prog` is specified on the command line, use this + -- instead of running the user's shell. + -- The value is the argument array, with the 0th element being + -- the executable to run. The path will be searched to locate + -- this if needed. + -- For example, to have `wezterm` always run `top` by default, + -- you'd use this: + default_prog = {"top"}, -# What to set the TERM variable to -term = "xterm-256color" + -- What to set the TERM variable to + term = "xterm-256color", -# Constrains the rate at which output from a child command is -# processed and applied to the terminal model. -# This acts as a brake in the case of a command spewing a -# ton of output and allows for the UI to remain responsive -# so that you can hit CTRL-C to interrupt it if desired. -# The default value is 200,000 bytes/s. -ratelimit_output_bytes_per_second = 200_000 + -- Constrains the rate at which output from a child command is + -- processed and applied to the terminal model. + -- This acts as a brake in the case of a command spewing a + -- ton of output and allows for the UI to remain responsive + -- so that you can hit CTRL-C to interrupt it if desired. + -- The default value is 200,000 bytes/s. + ratelimit_output_bytes_per_second = 200_000, -# Constrains the rate at which the multiplexer server will -# unilaterally push data to the client. -# This helps to avoid saturating the link between the client -# and server. -# Each time the screen is updated as a result of the child -# command outputting data (rather than in response to input -# from the client), the server considers whether to push -# the result to the client. -# That decision is throttled by this configuration value -# which has a default value of 10/s -ratelimit_mux_output_pushes_per_second = 10 + -- Constrains the rate at which the multiplexer server will + -- unilaterally push data to the client. + -- This helps to avoid saturating the link between the client + -- and server. + -- Each time the screen is updated as a result of the child + -- command outputting data (rather than in response to input + -- from the client), the server considers whether to push + -- the result to the client. + -- That decision is throttled by this configuration value + -- which has a default value of 10/s + ratelimit_mux_output_pushes_per_second = 10, -# Constrain how often the mux server scans the terminal -# model to compute a diff to send to the mux client. -# The default value is 100/s -ratelimit_mux_output_scans_per_second = 100 + -- Constrain how often the mux server scans the terminal + -- model to compute a diff to send to the mux client. + -- The default value is 100/s + ratelimit_mux_output_scans_per_second = 100, -# If false, do not try to use a Wayland protocol connection -# when starting the gui frontend, and instead use X11. -# This option is only considered on X11/Wayland systems and -# has no effect on macOS or Windows. -# The default is true. -enable_wayland = true + -- If false, do not try to use a Wayland protocol connection + -- when starting the gui frontend, and instead use X11. + -- This option is only considered on X11/Wayland systems and + -- has no effect on macOS or Windows. + -- The default is true. + enable_wayland = true, + -- Specifies how often a blinking cursor transitions between visible + -- and invisible, expressed in milliseconds. + -- Setting this to 0 disables blinking. + -- Note that this value is approximate due to the way that the system + -- event loop schedulers manage timers; non-zero values will be at + -- least the interval specified with some degree of slop. + -- It is recommended to avoid blinking cursors when on battery power, + -- as it is relatively costly to keep re-rendering for the blink! + cursor_blink_rate = 800, -# Specifies how often a blinking cursor transitions between visible -# and invisible, expressed in milliseconds. -# Setting this to 0 disables blinking. -# Note that this value is approximate due to the way that the system -# event loop schedulers manage timers; non-zero values will be at -# least the interval specified with some degree of slop. -# It is recommended to avoid blinking cursors when on battery power, -# as it is relatively costly to keep re-rendering for the blink! -cursor_blink_rate = 800 - -# Specifies the default cursor style. various escape sequences -# can override the default style in different situations (eg: -# an editor can change it depending on the mode), but this value -# controls how the cursor appears when it is reset to default. -# The default is `SteadyBlock`. -# Acceptable values are `SteadyBlock`, `BlinkingBlock`, -# `SteadyUnderline`, `BlinkingUnderline`, `SteadyBar`, -# and `BlinkingBar`. -default_cursor_style = "SteadyBlock" + -- Specifies the default cursor style. various escape sequences + -- can override the default style in different situations (eg: + -- an editor can change it depending on the mode), but this value + -- controls how the cursor appears when it is reset to default. + -- The default is `SteadyBlock`. + -- Acceptable values are `SteadyBlock`, `BlinkingBlock`, + -- `SteadyUnderline`, `BlinkingUnderline`, `SteadyBar`, + -- and `BlinkingBar`. + default_cursor_style = "SteadyBlock", +} ``` diff --git a/docs/faq.markdown b/docs/faq.markdown index dfde4a078..1dca87470 100644 --- a/docs/faq.markdown +++ b/docs/faq.markdown @@ -54,15 +54,18 @@ the worst cases spaces where a glyph should be, then you have an issue with font fallback. You can resolve this by explicitly adding fallback font(s) the have the glyphs -that you need in your `wezterm.toml`: +that you need in your `.wezterm.lua`: -```toml -[[font.font]] -family = "My Preferred Font" +```lua +local wezterm = require 'wezterm'; -# This font has a broader selection of Chinese glyphs than my preferred font -[[font.font]] -family = "DengXian" +return { + font = wezterm.font_with_fallback({ + "My Preferred Font", + -- This font has a broader selection of Chinese glyphs than my preferred font + "DengXian" + }) +} ``` ### Some (but not all) Emoji don't render properly diff --git a/docs/hyperlinks.markdown b/docs/hyperlinks.markdown index 51b123f3c..32281f304 100644 --- a/docs/hyperlinks.markdown +++ b/docs/hyperlinks.markdown @@ -10,24 +10,35 @@ to match URLs and make them clickable, but you can also specify your own rules to make your own links. As an example, at my place of work many of our internal tools use `T123` to indicate task number 123 in our internal task tracking system. It is desirable to make this clickable, and that can be done with the following -configuration: +configuration in your `~/.wezterm.lua`: -```toml -# Linkify things that look like URLs -# This is actually the default if you don't specify any hyperlink_rules -[[hyperlink_rules]] -regex = "\\b\\w+://(?:[\\w.-]+)\\.[a-z]{2,15}\\S*\\b" -format = "$0" +```lua +return { + hyperlink_rules = { + -- Linkify things that look like URLs + -- This is actually the default if you don't specify any hyperlink_rules + { + regex = "\\b\\w+://(?:[\\w.-]+)\\.[a-z]{2,15}\\S*\\b", + format = "$0", + }, -# Un-comment this if you want to linkify email addresses -#[[hyperlink_rules]] -#regex = "\\b\\w+@[\\w-]+(\\.[\\w-]+)+\\b" -#format = "mailto:$0" + -- Un-comment this if you want to linkify email addresses + --[[ + { + regex = "\\b\\w+@[\\w-]+(\\.[\\w-]+)+\\b", + format = "mailto:$0", + }, + ]] -# Make task numbers clickable -[[hyperlink_rules]] -regex = "\\b[tT](\\d+)\\b" -format = "https://example.com/tasks/?t=$1" + -- Make task numbers clickable + --[[ + { + regex = "\\b[tT](\\d+)\\b" + format = "https://example.com/tasks/?t=$1" + } + ]] + } +} ``` ### Explicit Hyperlinks diff --git a/docs/multiplexing.markdown b/docs/multiplexing.markdown index f27eb5ccd..ab4d235ec 100644 --- a/docs/multiplexing.markdown +++ b/docs/multiplexing.markdown @@ -32,21 +32,26 @@ installed on the remote system in order to use SSH domains**. SSH domains are supported on all systems via libssh2. To configure an SSH domain, place something like the following in -your `wezterm.toml` file: +your `.wezterm.lua` file: -``` -[[ssh_domains]] -# This name identifies the domain -name = "my.server" -# The address to connect to -remote_address = "192.168.1.1" -# The username to use on the remote host -username = "wez" +```lua +return { + ssh_domains = { + { + -- This name identifies the domain + name = "my.server", + -- The address to connect to + remote_address = "192.168.1.1", + -- The username to use on the remote host + username = "wez", + } + } +} ``` To connect to the system, run: -``` +```bash $ wezterm connect my.server ``` @@ -68,72 +73,96 @@ The bare minimum configuration to enable a unix domain is this, which will spawn a server if needed and then connect the gui to it automatically when wezterm is launched: -```toml -[[unix_domains]] -name = "unix" -connect_automatically = true +```lua +return { + unix_domains = { + { + name = "unix", + connect_automatically = true, + } + } +} ``` If you prefer to connect manually, omit the `connect_automatically` setting (or set it to `false`) and then run: -``` +```bash $ wezterm connect unix ``` The possible configuration values are: -```toml -[[unix_domains]] -name = "unix" -# If true, connect to this unix domain when `wezterm` is started -connect_automatically = true +```lua +return { + unix_domains = { + { + name = "unix", + -- If true, connect to this unix domain when `wezterm` is started + connect_automatically = true, -# The path to the socket. If unspecified, a resonable default -# value will be computed. -# socket_path = "/some/path" + -- The path to the socket. If unspecified, a resonable default + -- value will be computed. -# If true, do not attempt to start this server if we try and fail to -# connect to it. -# no_serve_automatically = false + -- socket_path = "/some/path", -# If true, bypass checking for secure ownership of the -# socket_path. This is not recommended on a multi-user -# system, but is useful for example when running the -# server inside a WSL container but with the socket -# on the host NTFS volume. -# skip_permissions_check = false + -- If true, do not attempt to start this server if we try and fail to + -- connect to it. + + -- no_serve_automatically = false, + + -- If true, bypass checking for secure ownership of the + -- socket_path. This is not recommended on a multi-user + -- system, but is useful for example when running the + -- server inside a WSL container but with the socket + -- on the host NTFS volume. + + -- skip_permissions_check = false, + + } + } +} ``` ### Connecting into Windows Subsystem for Linux -Inside your WSL instance, configure `wezterm.toml` with this snippet: +Inside your WSL instance, configure `.wezterm.lua` with this snippet: -```toml -[[unix_domains]] -name = "wsl" -# Override the default path to match the default on the host win32 -# filesystem. This will allow the host to connect into the WSL -# container. -socket_path = "/mnt/c/Users/USERNAME/.local/share/wezterm/sock" -# NTFS permissions will always be "wrong", so skip that check -skip_permissions_check = true +```lua +return { + unix_domains = { + { + name = "wsl" + -- Override the default path to match the default on the host win32 + -- filesystem. This will allow the host to connect into the WSL + -- container. + socket_path = "/mnt/c/Users/USERNAME/.local/share/wezterm/sock", + -- NTFS permissions will always be "wrong", so skip that check + skip_permissions_check = true, + } + } +} ``` In the host win32 configuration, use this snippet: -```toml -[[unix_domains]] -name = "wsl" -connect_automatically = true -serve_command = ["wsl", "wezterm", "start", "--daemonize", "--front-end", "MuxServer"] +```lua +return { + unix_domains = { + { + name = "wsl", + connect_automatically = true, + serve_command = ["wsl", "wezterm", "start", "--daemonize", "--front-end", "MuxServer"], + } + } +} ``` Now when you start wezterm you'll be presented with a WSL tab. You can also set `connect_automatically = false` and use: -``` +```bash $ wezterm connect wsl ``` @@ -154,25 +183,35 @@ server. For each server that you wish to connect to, add a client section like this: -```toml -[[tls_clients]] -# A handy alias for this session; you will use `wezterm connect server.name` -# to connect to it. -name = "server.name" -# The host:port for the remote host -remote_address = "server.hostname:8080" -# The value can be "user@host:port"; it accepts the same syntax as the -# `wezterm ssh` subcommand. -bootstrap_via_ssh = "server.hostname" +```lua +return { + tls_clients = { + { + -- A handy alias for this session; you will use `wezterm connect server.name` + -- to connect to it. + name = "server.name", + -- The host:port for the remote host + remote_address = "server.hostname:8080", + -- The value can be "user@host:port"; it accepts the same syntax as the + -- `wezterm ssh` subcommand. + bootstrap_via_ssh = "server.hostname", + } + } +} ``` ### Configuring the server -```toml -[[tls_servers]] -# The host:port combination on which the server will listen -# for connections -bind_address = "server.hostname:8080" +```lua +return { + tls_servers = { + { + -- The host:port combination on which the server will listen + -- for connections + bind_address = "server.hostname:8080" + } + } +} ``` ### Connecting diff --git a/docs/serial.markdown b/docs/serial.markdown index 8978da122..c5f9a61c0 100644 --- a/docs/serial.markdown +++ b/docs/serial.markdown @@ -6,19 +6,19 @@ when connecting to a serial console on a headless server. For example, on Linux: -``` +```bash $ wezterm serial /dev/ttyUSB0 ``` or on Windows: -``` +```bash $ wezterm serial COM0 ``` You can also specify the baud rate: -``` +```bash $ wezterm serial --baud 38400 /dev/ttyUSB0 ``` diff --git a/docs/shell-integration.markdown b/docs/shell-integration.markdown index 0968e9839..6887d2ccd 100644 --- a/docs/shell-integration.markdown +++ b/docs/shell-integration.markdown @@ -33,14 +33,17 @@ for yourself. `cmd.exe` doesn't allow a lot of flexibility in configuring the prompt, but fortunately it does allow for emitting escape sequences. You can use the `set_environment_variables` configuration to pre-configure -the prompt environment in your `wezterm.toml`; this example configures +the prompt environment in your `.wezterm.lua`; this example configures the use of OSC 7 as well as including the time and current directory in the visible prompt with green and purple colors, and makes the prompt span multiple lines: -```toml -[set_environment_variables] -prompt = "$E]7;file://localhost/$P$E\\$E[32m$T$E[0m $E[35m$P$E[36m$_$G$E[0m " +```lua +return { + set_environment_variables = { + prompt = "$E]7;file://localhost/$P$E\\$E[32m$T$E[0m $E[35m$P$E[36m$_$G$E[0m ", + } +} ``` ## Using clink on Windows Systems @@ -48,11 +51,13 @@ prompt = "$E]7;file://localhost/$P$E\\$E[32m$T$E[0m $E[35m$P$E[36m$_$G$E[0m " [Clink](https://github.com/mridgers/clink) brings bash style line editing to your Windows cmd.exe experience. If you haven't installed clink to be the global default on your system, you can configure wezterm to launch clink by -setting the `default_prog` configuration in your `wezterm.toml`; for example, +setting the `default_prog` configuration in your `.wezterm.lua`; for example, if you have extracted clink to `c:\clink_0.4.9` you might configure this: -```toml -default_prog = ["cmd.exe", "/s", "/k", "c:/clink_0.4.9/clink_x64.exe", "inject", "-q"] +```lua +return { + default_prog = {"cmd.exe", "/s", "/k", "c:/clink_0.4.9/clink_x64.exe", "inject", "-q"} +} ``` Now, rather than just running `cmd.exe` on its own, this will cause `cmd.exe` diff --git a/docs/ssh.markdown b/docs/ssh.markdown index b54ccf4d0..cde595764 100644 --- a/docs/ssh.markdown +++ b/docs/ssh.markdown @@ -4,7 +4,7 @@ wezterm uses libssh2 to provide an integrated SSH client. The client can be used to make ad-hoc SSH connections to remote hosts by invoking the client: -``` +```bash $ wezterm ssh wez@my.server ```