diff --git a/docs/hyperlinks.md b/docs/hyperlinks.md index 147a67f3e..8724b03be 100644 --- a/docs/hyperlinks.md +++ b/docs/hyperlinks.md @@ -14,13 +14,14 @@ in your `~/.wezterm.lua`: ```lua local wezterm = require 'wezterm' +local config = {} -- Use the defaults as a base -local hyperlink_rules = wezterm.default_hyperlink_rules() +config.hyperlink_rules = wezterm.default_hyperlink_rules() -- make task numbers clickable -- the first matched regex group is captured in $1. -table.insert(hyperlink_rules, { +table.insert(config.hyperlink_rules, { regex = [[\b[tt](\d+)\b]], format = 'https://example.com/tasks/?t=$1', }) @@ -29,14 +30,12 @@ table.insert(hyperlink_rules, { -- ( "nvim-treesitter/nvim-treesitter" | wbthomason/packer.nvim | wez/wezterm | "wez/wezterm.git" ) -- as long as a full url hyperlink regex exists above this it should not match a full url to -- github or gitlab / bitbucket (i.e. https://gitlab.com/user/project.git is still a whole clickable url) -table.insert(hyperlink_rules, { +table.insert(config.hyperlink_rules, { regex = [[["]?([\w\d]{1}[-\w\d]+)(/){1}([-\w\d\.]+)["]?]], format = 'https://www.github.com/$1/$3', }) -return { - hyperlink_rules = hyperlink_rules, -} +return config ``` See also [hyperlink_rules](config/lua/config/hyperlink_rules.md) and diff --git a/docs/multiplexing.md b/docs/multiplexing.md index fc62640c2..f73c9bad9 100644 --- a/docs/multiplexing.md +++ b/docs/multiplexing.md @@ -35,17 +35,15 @@ To configure an SSH domain, place something like the following in your `.wezterm.lua` file: ```lua -return { - ssh_domains = { - { - -- This name identifies the domain - name = 'my.server', - -- The hostname or address to connect to. Will be used to match settings - -- from your ssh config file - remote_address = '192.168.1.1', - -- The username to use on the remote host - username = 'wez', - }, +config.ssh_domains = { + { + -- This name identifies the domain + name = 'my.server', + -- The hostname or address to connect to. Will be used to match settings + -- from your ssh config file + remote_address = '192.168.1.1', + -- The username to use on the remote host + username = 'wez', }, } ``` @@ -78,19 +76,17 @@ spawn a server if needed and then connect the gui to it automatically when wezterm is launched: ```lua -return { - unix_domains = { - { - name = 'unix', - }, +config.unix_domains = { + { + name = 'unix', }, - - -- This causes `wezterm` to act as though it was started as - -- `wezterm connect unix` by default, connecting to the unix - -- domain on startup. - -- If you prefer to connect manually, leave out this line. - default_gui_startup_args = { 'connect', 'unix' }, } + +-- This causes `wezterm` to act as though it was started as +-- `wezterm connect unix` by default, connecting to the unix +-- domain on startup. +-- If you prefer to connect manually, leave out this line. +config.default_gui_startup_args = { 'connect', 'unix' } ``` If you prefer to connect manually, omit the `default_gui_startup_args` setting @@ -107,30 +103,28 @@ option was shown as the way to connect on startup. Using The possible configuration values are: ```lua -return { - unix_domains = { - { - -- The name; must be unique amongst all domains - name = 'unix', +config.unix_domains = { + { + -- The name; must be unique amongst all domains + name = 'unix', - -- The path to the socket. If unspecified, a resonable default - -- value will be computed. + -- The path to the socket. If unspecified, a resonable default + -- value will be computed. - -- socket_path = "/some/path", + -- socket_path = "/some/path", - -- If true, do not attempt to start this server if we try and fail to - -- connect to it. + -- If true, do not attempt to start this server if we try and fail to + -- connect to it. - -- no_serve_automatically = false, + -- 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. + -- 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, - }, + -- skip_permissions_check = false, }, } ``` @@ -147,12 +141,10 @@ but may help with the WSL 2 issue mentioned below when translated to an appropriate invocation of netcat/socat on Windows: ```lua -return { - unix_domains = { - { - name = 'unix', - proxy_command = { 'nc', '-U', '/Users/wez/.local/share/wezterm/sock' }, - }, +config.unix_domains = { + { + name = 'unix', + proxy_command = { 'nc', '-U', '/Users/wez/.local/share/wezterm/sock' }, }, } ``` @@ -167,12 +159,10 @@ result of that prediction locally without waiting, hence hiding latency to the user. This option only applies when `multiplexing = "WezTerm"`. ```lua -return { - unix_domains = { - { - name = 'unix', - local_echo_threshold_ms = 10, - }, +config.unix_domains = { + { + name = 'unix', + local_echo_threshold_ms = 10, }, } ``` @@ -184,17 +174,15 @@ return { Inside your WSL instance, configure `.wezterm.lua` with this snippet: ```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, - }, +config.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, }, } ``` @@ -202,15 +190,13 @@ return { In the host win32 configuration, use this snippet: ```lua -return { - unix_domains = { - { - name = 'wsl', - serve_command = { 'wsl', 'wezterm-mux-server', '--daemonize' }, - }, +config.unix_domains = { + { + name = 'wsl', + serve_command = { 'wsl', 'wezterm-mux-server', '--daemonize' }, }, - default_gui_startup_args = { 'connect', 'wsl' }, } +config.default_gui_startup_args = { 'connect', 'wsl' } ``` Now when you start wezterm you'll be presented with a WSL tab. @@ -239,18 +225,16 @@ server. For each server that you wish to connect to, add a client section like this: ```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', - }, +config.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', }, } ``` @@ -261,13 +245,11 @@ settings. ### Configuring the server ```lua -return { - tls_servers = { - { - -- The host:port combination on which the server will listen - -- for connections - bind_address = 'server.hostname:8080', - }, +config.tls_servers = { + { + -- The host:port combination on which the server will listen + -- for connections + bind_address = 'server.hostname:8080', }, } ``` diff --git a/docs/scrollback.md b/docs/scrollback.md index 4e664cee0..707283c31 100644 --- a/docs/scrollback.md +++ b/docs/scrollback.md @@ -18,10 +18,8 @@ may put some pressure on your system depending on the amount of RAM you have available. ```lua -return { - -- How many lines of scrollback you want to retain per tab - scrollback_lines = 3500, -} +-- How many lines of scrollback you want to retain per tab +config.scrollback_lines = 3500 ``` ### Clearing the scrollback buffer @@ -39,13 +37,11 @@ You can control whether WezTerm displays a scrollbar via your configuration file: ```lua -return { - -- Enable the scrollbar. - -- 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. +-- 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 +config.enable_scroll_bar = true ``` You may [change the color of the scrollbar](config/appearance.md#defining-your-own-colors) if you wish! @@ -117,15 +113,12 @@ for your mouse to copy and paste a relevant git commit hash then you might like this: ```lua -local wezterm = require 'wezterm' -return { - keys = { - -- search for things that look like git hashes - { - key = 'H', - mods = 'SHIFT|CTRL', - action = wezterm.action.Search { Regex = '[a-f0-9]{6,}' }, - }, +config.keys = { + -- search for things that look like git hashes + { + key = 'H', + mods = 'SHIFT|CTRL', + action = wezterm.action.Search { Regex = '[a-f0-9]{6,}' }, }, } ``` diff --git a/docs/shell-integration.md b/docs/shell-integration.md index acdff54b9..1bcaed0ab 100644 --- a/docs/shell-integration.md +++ b/docs/shell-integration.md @@ -100,10 +100,8 @@ the visible prompt with green and purple colors, and makes the prompt span multiple lines: ```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 ', - }, +config.set_environment_variables = { + prompt = '$E]7;file://localhost/$P$E\\$E[32m$T$E[0m $E[35m$P$E[36m$_$G$E[0m ', } ``` @@ -154,25 +152,22 @@ you might configure this: ```lua local wezterm = require 'wezterm' +local config = {} -local default_prog -local set_environment_variables = {} +config.set_environment_variables = {} if wezterm.target_triple == 'x86_64-pc-windows-msvc' then -- Use OSC 7 as per the above example - set_environment_variables['prompt'] = + config.set_environment_variables['prompt'] = '$E]7;file://localhost/$P$E\\$E[32m$T$E[0m $E[35m$P$E[36m$_$G$E[0m ' -- use a more ls-like output format for dir - set_environment_variables['DIRCMD'] = '/d' + config.set_environment_variables['DIRCMD'] = '/d' -- And inject clink into the command prompt - default_prog = + config.default_prog = { 'cmd.exe', '/s', '/k', 'c:/clink/clink_x64.exe', 'inject', '-q' } end -return { - default_prog = default_prog, - set_environment_variables = set_environment_variables, -} +return config ``` Now, rather than just running `cmd.exe` on its own, this will cause `cmd.exe`