Skip to content

Instantly share code, notes, and snippets.

@lessmost
Last active March 27, 2025 14:00
Show Gist options
  • Save lessmost/dac76d77991efd168af2c7e5785a1b76 to your computer and use it in GitHub Desktop.
Save lessmost/dac76d77991efd168af2c7e5785a1b76 to your computer and use it in GitHub Desktop.
-- Pull in the wezterm API
local wezterm = require("wezterm")
local mux = wezterm.mux
-- This will hold the configuration.
local config = wezterm.config_builder()
-- This is where you actually apply your config choices
-- For example, changing the color scheme:
config.color_scheme = "Catppuccin Mocha"
-- config.color_scheme = "One Dark (Gogh)"
config.font_size = 13
-- config.window_decorations = "RESIZE|INTEGRATED_BUTTONS"
config.window_decorations = "RESIZE"
-- config.window_background_opacity = 0.9
-- config.macos_window_background_blur = 30
-- Sets the font for the window frame (tab bar)
config.native_macos_fullscreen_mode = true
config.window_frame = {
-- font = wezterm.font({ family = "Serif", weight = "Thin" }),
font_size = 10,
}
config.window_padding = {
top = 0,
left = 0,
right = 0,
bottom = 0,
}
-- config.window_background_image = "/Users/zqlu/Documents/wallhavens/alita1.png"
-- config.window_background_image = "/Users/zqlu/Downloads/Images/vi.png"
-- config.window_background_image = "/Users/zqlu/Downloads/Images/2b.png"
-- config.window_background_image = "/Users/zqlu/Downloads/Images/wallhaven-o5r51p_3840x2160.png"
config.window_background_image_hsb = {
brightness = 0.02,
hue = 1.0,
saturation = 0.9,
}
config.set_environment_variables = {
http_proxy = "http://127.0.0.1:7897",
https_proxy = "http://127.0.0.1:7897",
all_proxy = "http://127.0.0.1:7897",
}
local ligature = {
"zero",
"calt=0",
"clig=0",
"liga=0",
"ss01",
"ss02",
"ss03",
"ss04",
"ss05",
"ss06",
"ss07",
"ss08",
}
config.font = wezterm.font({
-- family = "IBM Plex Mono",
family = "MonaspiceAr Nerd Font Mono",
-- family = "JetBrains Mono",
harfbuzz_features = ligature,
})
config.font_rules = {
{
intensity = "Bold",
italic = true,
font = wezterm.font({
family = "MonaspiceRn Nerd Font Mono",
weight = "Bold",
style = "Italic",
harfbuzz_features = ligature,
}),
},
{
italic = true,
intensity = "Half",
font = wezterm.font({
family = "MonaspiceRn Nerd Font Mono",
weight = "DemiBold",
style = "Italic",
harfbuzz_features = ligature,
}),
},
{
italic = true,
intensity = "Normal",
font = wezterm.font({
family = "MonaspiceRn Nerd Font Mono",
style = "Italic",
harfbuzz_features = ligature,
}),
},
}
config.tab_bar_at_bottom = true
config.hide_tab_bar_if_only_one_tab = true
config.use_fancy_tab_bar = false
config.leader = { key = "a", mods = "CTRL" }
config.keys = {
-- { key = "f", mods = "CTRL|CMD", action = wezterm.action.ToggleFullScreen },
{ key = "p", mods = "LEADER", action = wezterm.action.ActivateCommandPalette },
{ key = "o", mods = "LEADER", action = wezterm.action.ShowLauncherArgs({ flags = "FUZZY|WORKSPACES" }) },
{ key = "a", mods = "LEADER|CTRL", action = wezterm.action({ SendString = "\x01" }) },
{
key = "-",
mods = "LEADER",
action = wezterm.action({ SplitVertical = { domain = "CurrentPaneDomain" } }),
},
{
key = "\\",
mods = "LEADER",
action = wezterm.action({ SplitHorizontal = { domain = "CurrentPaneDomain" } }),
},
{
key = "s",
mods = "LEADER",
action = wezterm.action({ SplitVertical = { domain = "CurrentPaneDomain" } }),
},
{
key = "v",
mods = "LEADER",
action = wezterm.action({ SplitHorizontal = { domain = "CurrentPaneDomain" } }),
},
{ key = "z", mods = "LEADER", action = "TogglePaneZoomState" },
-- { key = "c", mods = "LEADER", action = wezterm.action({ SpawnTab = "DefaultDomain" }) },
{ key = "c", mods = "LEADER", action = wezterm.action.SpawnCommandInNewTab({ cwd = wezterm.home_dir }) },
{ key = "h", mods = "LEADER", action = wezterm.action({ ActivatePaneDirection = "Left" }) },
{ key = "j", mods = "LEADER", action = wezterm.action({ ActivatePaneDirection = "Down" }) },
{ key = "k", mods = "LEADER", action = wezterm.action({ ActivatePaneDirection = "Up" }) },
{ key = "l", mods = "LEADER", action = wezterm.action({ ActivatePaneDirection = "Right" }) },
{ key = "H", mods = "LEADER|SHIFT", action = wezterm.action({ AdjustPaneSize = { "Left", 5 } }) },
{ key = "J", mods = "LEADER|SHIFT", action = wezterm.action({ AdjustPaneSize = { "Down", 5 } }) },
{ key = "K", mods = "LEADER|SHIFT", action = wezterm.action({ AdjustPaneSize = { "Up", 5 } }) },
{ key = "L", mods = "LEADER|SHIFT", action = wezterm.action({ AdjustPaneSize = { "Right", 5 } }) },
-- { key = "o", mods = "LEADER", action = wezterm.action.ActivateLastTab },
{ key = "a", mods = "LEADER", action = wezterm.action.ActivateLastTab },
{ key = "1", mods = "LEADER", action = wezterm.action({ ActivateTab = 0 }) },
{ key = "2", mods = "LEADER", action = wezterm.action({ ActivateTab = 1 }) },
{ key = "3", mods = "LEADER", action = wezterm.action({ ActivateTab = 2 }) },
{ key = "4", mods = "LEADER", action = wezterm.action({ ActivateTab = 3 }) },
{ key = "5", mods = "LEADER", action = wezterm.action({ ActivateTab = 4 }) },
{ key = "6", mods = "LEADER", action = wezterm.action({ ActivateTab = 5 }) },
{ key = "7", mods = "LEADER", action = wezterm.action({ ActivateTab = 6 }) },
{ key = "8", mods = "LEADER", action = wezterm.action({ ActivateTab = 7 }) },
{ key = "9", mods = "LEADER", action = wezterm.action({ ActivateTab = 8 }) },
{ key = "1", mods = "ALT", action = wezterm.action.ActivatePaneByIndex(0) },
{ key = "2", mods = "ALT", action = wezterm.action.ActivatePaneByIndex(1) },
{ key = "3", mods = "ALT", action = wezterm.action.ActivatePaneByIndex(2) },
{ key = "4", mods = "ALT", action = wezterm.action.ActivatePaneByIndex(3) },
{ key = "5", mods = "ALT", action = wezterm.action.ActivatePaneByIndex(4) },
{ key = "&", mods = "LEADER|SHIFT", action = wezterm.action({ CloseCurrentTab = { confirm = true } }) },
{ key = "d", mods = "LEADER", action = wezterm.action({ CloseCurrentPane = { confirm = true } }) },
{ key = "x", mods = "LEADER", action = wezterm.action({ CloseCurrentPane = { confirm = true } }) },
{ key = "[", mods = "LEADER", action = wezterm.action.QuickSelect }, -- enter quick select mode
{ key = "]", mods = "LEADER", action = wezterm.action.ActivateCopyMode }, -- enter copy mode
{ key = "z", mods = "LEADER|CTRL", action = wezterm.action.EmitEvent("toggle-tabbar") },
{
key = "K",
mods = "CTRL|SHIFT",
action = wezterm.action.Multiple({
wezterm.action.ClearScrollback("ScrollbackAndViewport"),
wezterm.action.SendKey({ key = "L", mods = "CTRL" }),
}),
},
}
wezterm.on("toggle-tabbar", function(window, _)
local overrides = window:get_config_overrides() or {}
if overrides.enable_tab_bar == false then
wezterm.log_info("tab bar shown")
overrides.enable_tab_bar = true
else
wezterm.log_info("tab bar hidden")
overrides.enable_tab_bar = false
end
window:set_config_overrides(overrides)
end)
wezterm.on("gui-startup", function(cmd)
local args = {}
if cmd then
args = cmd.args
end
-- setup default workspace
local tab, pane, window = mux.spawn_window({
workspace = "default",
cwd = wezterm.home_dir .. "/Worktrees",
args = args,
})
window:spawn_tab({
cwd = wezterm.home_dir .. "/Sources",
})
-- active the first tab
tab:activate()
-- setup personal workspace
local p_tab, p_panel, p_window = mux.spawn_window({
workspace = "personal",
cwd = wezterm.home_dir .. "/Projects",
args = args,
})
p_window:spawn_tab({
cwd = wezterm.home_dir .. "/Sources",
})
p_tab:activate()
-- switch to default workspace and maximize the window
mux.set_active_workspace("default")
-- window:gui_window():maximize()
local screen = wezterm.gui.screens()["active"]
local width = screen.width * 0.9
local height = screen.height * 0.9 - 24
window:gui_window():set_inner_size(width, height)
window
:gui_window()
:set_position(screen.x + (screen.width - width) / 2, screen.y + (screen.height - height) / 2 + 24)
end)
wezterm.on("update-right-status", function(window, pane)
window:set_right_status(window:active_workspace())
end)
-- and finally, return the configuration to wezterm
return config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment