wezterm.lua
· 8.0 KiB · Lua
Raw
-- Pull in the wezterm API, some of its modules, and plugins
local wezterm = require 'wezterm'
local act = wezterm.action
local merge = require 'merge'
local mux = wezterm.mux
local resurrect = require 'resurrect/config'
local smart_splits = require 'smart-splits/setup'
-- --------------------------------------------------------------------
-- CONFIGURATION
-- --------------------------------------------------------------------
-- This table will hold the configuration.
local config = {}
-- In newer versions of wezterm, use the config_builder which will
-- help provide clearer error messages
if wezterm.config_builder then
config = wezterm.config_builder()
end
config.adjust_window_size_when_changing_font_size = false
config.automatically_reload_config = true
config.color_scheme = 'Solarized (dark) (terminal.sexy)'
config.enable_scroll_bar = true
config.enable_wayland = true
-- config.font = wezterm.font('Hack')
config.font = wezterm.font('MonaspiceNe NFP')
config.font_size = 12.0
config.hide_tab_bar_if_only_one_tab = false
-- The leader is similar to how tmux defines a set of keys to hit in order to
-- invoke tmux bindings. Binding to ctrl-a here to mimic tmux
config.leader = { key = 'a', mods = 'CTRL', timeout_milliseconds = 2000 }
config.mouse_bindings = {
-- Open URLs with Ctrl+Click
{
event = { Up = { streak = 1, button = 'Left' } },
mods = 'CTRL',
action = act.OpenLinkAtMouseCursor,
}
}
config.pane_focus_follows_mouse = true
config.scrollback_lines = 5000
config.tiling_desktop_environments = {
'Wayland',
}
config.use_dead_keys = false
config.warn_about_missing_glyphs = false
config.window_decorations = "TITLE | RESIZE"
config.window_padding = {
left = 0,
right = 0,
top = 0,
bottom = 0,
}
-- Tab bar
config.use_fancy_tab_bar = true
config.tab_bar_at_bottom = true
config.switch_to_last_active_tab_when_closing_tab = true
config.tab_max_width = 32
config.colors = {
quick_select_label_bg = { Color = '#fdf6e3' },
quick_select_label_fg = { Color = '#073642' },
tab_bar = {
active_tab = {
fg_color = '#073642',
bg_color = '#2aa198',
}
}
}
-- Add items to launch menu
config.launch_menu = {
{
label = 'mwop',
cwd = wezterm.home_dir .. '/git/weierophinney/mwop.net',
},
{
label = 'onedrive',
cwd = wezterm.home_dir .. '/OneDrive',
},
{
label = 'top',
args = { 'top' },
},
}
-- Custom key bindings
config.keys = {
-- Show the launcher
{
key = 'm',
mods = 'LEADER',
action = act.ShowLauncher,
},
-- Copy mode
{
key = '[',
mods = 'LEADER',
action = act.ActivateCopyMode,
},
-- ----------------------------------------------------------------
-- TABS
--
-- Where possible, I'm using the same combinations as I would in tmux
-- ----------------------------------------------------------------
-- Show tab navigator; similar to listing panes in tmux
{
key = 'w',
mods = 'LEADER',
action = act.ShowTabNavigator,
},
-- Create a tab (alternative to Ctrl-Shift-Tab)
{
key = 'c',
mods = 'LEADER',
action = act.SpawnTab 'CurrentPaneDomain',
},
-- Rename current tab; analagous to command in tmux
{
key = ',',
mods = 'LEADER',
action = act.PromptInputLine {
description = 'Enter new name for tab',
action = wezterm.action_callback(
function(window, pane, line) -- luacheck: ignore 212
if line then
window:active_tab():set_title(line)
end
end
),
},
},
-- Move to next/previous TAB
{
key = 'n',
mods = 'LEADER',
action = act.ActivateTabRelative(1),
},
{
key = 'p',
mods = 'LEADER',
action = act.ActivateTabRelative(-1),
},
-- Close tab
{
key = '&',
mods = 'LEADER|SHIFT',
action = act.CloseCurrentTab{ confirm = true },
},
-- ----------------------------------------------------------------
-- PANES
--
-- These are great and get me most of the way to replacing tmux
-- entirely, particularly as you can use "wezterm ssh" to ssh to another
-- server, and still retain Wezterm as your terminal there.
--
-- Note that these only define creating splits, relative motion
-- (next/previous), zooming, swapping, and killing panes; actual directional
-- motions between panes or resizing them are handled by smart splits.
-- ----------------------------------------------------------------
-- Vertical split
{
-- |
key = '|',
mods = 'LEADER|SHIFT',
action = act.SplitPane {
direction = 'Right',
size = { Percent = 50 },
},
},
-- Horizontal split
{
-- -
key = '-',
mods = 'LEADER',
action = act.SplitPane {
direction = 'Down',
size = { Percent = 50 },
},
},
-- Close/kill active pane
{
key = 'x',
mods = 'LEADER',
action = act.CloseCurrentPane { confirm = true },
},
-- Swap active pane with another one
{
key = '{',
mods = 'LEADER|SHIFT',
action = act.PaneSelect { mode = "SwapWithActiveKeepFocus" },
},
-- Zoom current pane (toggle)
{
key = 'z',
mods = 'LEADER',
action = act.TogglePaneZoomState,
},
{
key = 'f',
mods = 'ALT',
action = act.TogglePaneZoomState,
},
-- Move to next/previous pane
{
key = ';',
mods = 'LEADER',
action = act.ActivatePaneDirection('Prev'),
},
{
key = 'o',
mods = 'LEADER',
action = act.ActivatePaneDirection('Next'),
},
-- ----------------------------------------------------------------
-- Workspaces
--
-- These are roughly equivalent to tmux sessions.
-- ----------------------------------------------------------------
-- Attach to muxer
{
key = 'a',
mods = 'LEADER',
action = act.AttachDomain 'unix',
},
-- Detach from muxer
{
key = 'd',
mods = 'LEADER',
action = act.DetachDomain { DomainName = 'unix' },
},
-- Show list of workspaces
{
key = 's',
mods = 'LEADER',
action = act.ShowLauncherArgs { flags = 'WORKSPACES' },
},
-- Rename current session; analagous to command in tmux
{
key = '$',
mods = 'LEADER|SHIFT',
action = act.PromptInputLine {
description = 'Enter new name for session',
action = wezterm.action_callback(
function(window, pane, line) -- luacheck: ignore 212
if line then
mux.rename_workspace(
window:mux_window():get_workspace(),
line
)
end
end
),
},
},
}
-- --------------------------------------------------------------------
-- Smart splits
--
-- See https://github.com/mrjones2014/smart-splits.nvim
--
-- Allows moving and resizing panes easily, as well as navigation between
-- wezterm and nvim panes
-- --------------------------------------------------------------------
config.keys = merge.all(config.keys, smart_splits.keys)
-- --------------------------------------------------------------------
-- resurrect.wezterm
--
-- See https://github.com/MLFlexer/resurrect.wezterm
-- See resurrect.lua
-- --------------------------------------------------------------------
config.keys = merge.all(config.keys, resurrect.keys)
-- Powerline for tab bar
require 'powerline'
-- Tab status
require 'tab-status'
-- Plugin management
-- Automatically update plugins
-- wezterm.plugin.update_all()
-- and finally, return the configuration to wezterm
return config
| 1 | -- Pull in the wezterm API, some of its modules, and plugins |
| 2 | local wezterm = require 'wezterm' |
| 3 | local act = wezterm.action |
| 4 | local merge = require 'merge' |
| 5 | local mux = wezterm.mux |
| 6 | local resurrect = require 'resurrect/config' |
| 7 | local smart_splits = require 'smart-splits/setup' |
| 8 | |
| 9 | -- -------------------------------------------------------------------- |
| 10 | -- CONFIGURATION |
| 11 | -- -------------------------------------------------------------------- |
| 12 | |
| 13 | -- This table will hold the configuration. |
| 14 | local config = {} |
| 15 | |
| 16 | -- In newer versions of wezterm, use the config_builder which will |
| 17 | -- help provide clearer error messages |
| 18 | if wezterm.config_builder then |
| 19 | config = wezterm.config_builder() |
| 20 | end |
| 21 | |
| 22 | config.adjust_window_size_when_changing_font_size = false |
| 23 | config.automatically_reload_config = true |
| 24 | config.color_scheme = 'Solarized (dark) (terminal.sexy)' |
| 25 | config.enable_scroll_bar = true |
| 26 | config.enable_wayland = true |
| 27 | -- config.font = wezterm.font('Hack') |
| 28 | config.font = wezterm.font('MonaspiceNe NFP') |
| 29 | config.font_size = 12.0 |
| 30 | config.hide_tab_bar_if_only_one_tab = false |
| 31 | -- The leader is similar to how tmux defines a set of keys to hit in order to |
| 32 | -- invoke tmux bindings. Binding to ctrl-a here to mimic tmux |
| 33 | config.leader = { key = 'a', mods = 'CTRL', timeout_milliseconds = 2000 } |
| 34 | config.mouse_bindings = { |
| 35 | -- Open URLs with Ctrl+Click |
| 36 | { |
| 37 | event = { Up = { streak = 1, button = 'Left' } }, |
| 38 | mods = 'CTRL', |
| 39 | action = act.OpenLinkAtMouseCursor, |
| 40 | } |
| 41 | } |
| 42 | config.pane_focus_follows_mouse = true |
| 43 | config.scrollback_lines = 5000 |
| 44 | config.tiling_desktop_environments = { |
| 45 | 'Wayland', |
| 46 | } |
| 47 | config.use_dead_keys = false |
| 48 | config.warn_about_missing_glyphs = false |
| 49 | config.window_decorations = "TITLE | RESIZE" |
| 50 | config.window_padding = { |
| 51 | left = 0, |
| 52 | right = 0, |
| 53 | top = 0, |
| 54 | bottom = 0, |
| 55 | } |
| 56 | |
| 57 | -- Tab bar |
| 58 | config.use_fancy_tab_bar = true |
| 59 | config.tab_bar_at_bottom = true |
| 60 | config.switch_to_last_active_tab_when_closing_tab = true |
| 61 | config.tab_max_width = 32 |
| 62 | config.colors = { |
| 63 | quick_select_label_bg = { Color = '#fdf6e3' }, |
| 64 | quick_select_label_fg = { Color = '#073642' }, |
| 65 | tab_bar = { |
| 66 | active_tab = { |
| 67 | fg_color = '#073642', |
| 68 | bg_color = '#2aa198', |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | -- Add items to launch menu |
| 74 | config.launch_menu = { |
| 75 | { |
| 76 | label = 'mwop', |
| 77 | cwd = wezterm.home_dir .. '/git/weierophinney/mwop.net', |
| 78 | }, |
| 79 | { |
| 80 | label = 'onedrive', |
| 81 | cwd = wezterm.home_dir .. '/OneDrive', |
| 82 | }, |
| 83 | { |
| 84 | label = 'top', |
| 85 | args = { 'top' }, |
| 86 | }, |
| 87 | } |
| 88 | |
| 89 | -- Custom key bindings |
| 90 | config.keys = { |
| 91 | -- Show the launcher |
| 92 | { |
| 93 | key = 'm', |
| 94 | mods = 'LEADER', |
| 95 | action = act.ShowLauncher, |
| 96 | }, |
| 97 | |
| 98 | -- Copy mode |
| 99 | { |
| 100 | key = '[', |
| 101 | mods = 'LEADER', |
| 102 | action = act.ActivateCopyMode, |
| 103 | }, |
| 104 | |
| 105 | -- ---------------------------------------------------------------- |
| 106 | -- TABS |
| 107 | -- |
| 108 | -- Where possible, I'm using the same combinations as I would in tmux |
| 109 | -- ---------------------------------------------------------------- |
| 110 | |
| 111 | -- Show tab navigator; similar to listing panes in tmux |
| 112 | { |
| 113 | key = 'w', |
| 114 | mods = 'LEADER', |
| 115 | action = act.ShowTabNavigator, |
| 116 | }, |
| 117 | |
| 118 | -- Create a tab (alternative to Ctrl-Shift-Tab) |
| 119 | { |
| 120 | key = 'c', |
| 121 | mods = 'LEADER', |
| 122 | action = act.SpawnTab 'CurrentPaneDomain', |
| 123 | }, |
| 124 | |
| 125 | -- Rename current tab; analagous to command in tmux |
| 126 | { |
| 127 | key = ',', |
| 128 | mods = 'LEADER', |
| 129 | action = act.PromptInputLine { |
| 130 | description = 'Enter new name for tab', |
| 131 | action = wezterm.action_callback( |
| 132 | function(window, pane, line) -- luacheck: ignore 212 |
| 133 | if line then |
| 134 | window:active_tab():set_title(line) |
| 135 | end |
| 136 | end |
| 137 | ), |
| 138 | }, |
| 139 | }, |
| 140 | |
| 141 | -- Move to next/previous TAB |
| 142 | { |
| 143 | key = 'n', |
| 144 | mods = 'LEADER', |
| 145 | action = act.ActivateTabRelative(1), |
| 146 | }, |
| 147 | { |
| 148 | key = 'p', |
| 149 | mods = 'LEADER', |
| 150 | action = act.ActivateTabRelative(-1), |
| 151 | }, |
| 152 | |
| 153 | -- Close tab |
| 154 | { |
| 155 | key = '&', |
| 156 | mods = 'LEADER|SHIFT', |
| 157 | action = act.CloseCurrentTab{ confirm = true }, |
| 158 | }, |
| 159 | |
| 160 | -- ---------------------------------------------------------------- |
| 161 | -- PANES |
| 162 | -- |
| 163 | -- These are great and get me most of the way to replacing tmux |
| 164 | -- entirely, particularly as you can use "wezterm ssh" to ssh to another |
| 165 | -- server, and still retain Wezterm as your terminal there. |
| 166 | -- |
| 167 | -- Note that these only define creating splits, relative motion |
| 168 | -- (next/previous), zooming, swapping, and killing panes; actual directional |
| 169 | -- motions between panes or resizing them are handled by smart splits. |
| 170 | -- ---------------------------------------------------------------- |
| 171 | |
| 172 | -- Vertical split |
| 173 | { |
| 174 | -- | |
| 175 | key = '|', |
| 176 | mods = 'LEADER|SHIFT', |
| 177 | action = act.SplitPane { |
| 178 | direction = 'Right', |
| 179 | size = { Percent = 50 }, |
| 180 | }, |
| 181 | }, |
| 182 | |
| 183 | -- Horizontal split |
| 184 | { |
| 185 | -- - |
| 186 | key = '-', |
| 187 | mods = 'LEADER', |
| 188 | action = act.SplitPane { |
| 189 | direction = 'Down', |
| 190 | size = { Percent = 50 }, |
| 191 | }, |
| 192 | }, |
| 193 | |
| 194 | -- Close/kill active pane |
| 195 | { |
| 196 | key = 'x', |
| 197 | mods = 'LEADER', |
| 198 | action = act.CloseCurrentPane { confirm = true }, |
| 199 | }, |
| 200 | |
| 201 | -- Swap active pane with another one |
| 202 | { |
| 203 | key = '{', |
| 204 | mods = 'LEADER|SHIFT', |
| 205 | action = act.PaneSelect { mode = "SwapWithActiveKeepFocus" }, |
| 206 | }, |
| 207 | |
| 208 | -- Zoom current pane (toggle) |
| 209 | { |
| 210 | key = 'z', |
| 211 | mods = 'LEADER', |
| 212 | action = act.TogglePaneZoomState, |
| 213 | }, |
| 214 | { |
| 215 | key = 'f', |
| 216 | mods = 'ALT', |
| 217 | action = act.TogglePaneZoomState, |
| 218 | }, |
| 219 | |
| 220 | -- Move to next/previous pane |
| 221 | { |
| 222 | key = ';', |
| 223 | mods = 'LEADER', |
| 224 | action = act.ActivatePaneDirection('Prev'), |
| 225 | }, |
| 226 | { |
| 227 | key = 'o', |
| 228 | mods = 'LEADER', |
| 229 | action = act.ActivatePaneDirection('Next'), |
| 230 | }, |
| 231 | |
| 232 | -- ---------------------------------------------------------------- |
| 233 | -- Workspaces |
| 234 | -- |
| 235 | -- These are roughly equivalent to tmux sessions. |
| 236 | -- ---------------------------------------------------------------- |
| 237 | |
| 238 | -- Attach to muxer |
| 239 | { |
| 240 | key = 'a', |
| 241 | mods = 'LEADER', |
| 242 | action = act.AttachDomain 'unix', |
| 243 | }, |
| 244 | |
| 245 | -- Detach from muxer |
| 246 | { |
| 247 | key = 'd', |
| 248 | mods = 'LEADER', |
| 249 | action = act.DetachDomain { DomainName = 'unix' }, |
| 250 | }, |
| 251 | |
| 252 | -- Show list of workspaces |
| 253 | { |
| 254 | key = 's', |
| 255 | mods = 'LEADER', |
| 256 | action = act.ShowLauncherArgs { flags = 'WORKSPACES' }, |
| 257 | }, |
| 258 | |
| 259 | -- Rename current session; analagous to command in tmux |
| 260 | { |
| 261 | key = '$', |
| 262 | mods = 'LEADER|SHIFT', |
| 263 | action = act.PromptInputLine { |
| 264 | description = 'Enter new name for session', |
| 265 | action = wezterm.action_callback( |
| 266 | function(window, pane, line) -- luacheck: ignore 212 |
| 267 | if line then |
| 268 | mux.rename_workspace( |
| 269 | window:mux_window():get_workspace(), |
| 270 | line |
| 271 | ) |
| 272 | end |
| 273 | end |
| 274 | ), |
| 275 | }, |
| 276 | }, |
| 277 | } |
| 278 | |
| 279 | -- -------------------------------------------------------------------- |
| 280 | -- Smart splits |
| 281 | -- |
| 282 | -- See https://github.com/mrjones2014/smart-splits.nvim |
| 283 | -- |
| 284 | -- Allows moving and resizing panes easily, as well as navigation between |
| 285 | -- wezterm and nvim panes |
| 286 | -- -------------------------------------------------------------------- |
| 287 | config.keys = merge.all(config.keys, smart_splits.keys) |
| 288 | |
| 289 | -- -------------------------------------------------------------------- |
| 290 | -- resurrect.wezterm |
| 291 | -- |
| 292 | -- See https://github.com/MLFlexer/resurrect.wezterm |
| 293 | -- See resurrect.lua |
| 294 | -- -------------------------------------------------------------------- |
| 295 | config.keys = merge.all(config.keys, resurrect.keys) |
| 296 | |
| 297 | -- Powerline for tab bar |
| 298 | require 'powerline' |
| 299 | |
| 300 | -- Tab status |
| 301 | require 'tab-status' |
| 302 | |
| 303 | -- Plugin management |
| 304 | -- Automatically update plugins |
| 305 | -- wezterm.plugin.update_all() |
| 306 | |
| 307 | -- and finally, return the configuration to wezterm |
| 308 | return config |