Last active
May 22, 2024 11:20
-
-
Save rikas/df407ebf7889ff98d1a5cf4386f76c5d to your computer and use it in GitHub Desktop.
My wezterm config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local wezterm = require("wezterm") | |
local act = wezterm.action | |
local mux = wezterm.mux | |
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 | |
-- This is mandatory for the pt-PT keyboard layout to work properly on MacOS | |
-- Where Alt or AltGr + shift + [8 or 9] is used to type { or } | |
config.send_composed_key_when_left_alt_is_pressed = true | |
-- config.color_scheme = "catppuccin-mocha" | |
config.color_scheme = "Jellybeans" | |
config.font = wezterm.font("JetBrainsMono Nerd Font") | |
config.font_size = 12.5 | |
config.bold_brightens_ansi_colors = "BrightAndBold" | |
config.cursor_blink_rate = 1500 | |
config.default_cursor_style = "BlinkingBar" | |
config.force_reverse_video_cursor = true | |
config.window_close_confirmation = "AlwaysPrompt" | |
config.default_workspace = "home" | |
config.native_macos_fullscreen_mode = true | |
-- Dim inactive panes | |
config.inactive_pane_hsb = { | |
saturation = 0.5, | |
brightness = 0.6, | |
} | |
-- Disables dead keys (~, ^, ´, `) on MacOS | |
config.use_dead_keys = false | |
-- Keys | |
config.leader = { key = "b", mods = "CTRL", timeout_milliseconds = 2000 } | |
config.keys = { | |
{ key = "c", mods = "LEADER", action = act.ActivateCopyMode }, | |
-- Panes | |
{ key = "-", mods = "LEADER", action = act.SplitVertical({ domain = "CurrentPaneDomain" }) }, | |
{ | |
key = "|", | |
mods = "LEADER|SHIFT", | |
action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }), | |
}, | |
{ key = "h", mods = "LEADER", action = act.ActivatePaneDirection("Left") }, | |
{ key = "j", mods = "LEADER", action = act.ActivatePaneDirection("Down") }, | |
{ key = "k", mods = "LEADER", action = act.ActivatePaneDirection("Up") }, | |
{ key = "l", mods = "LEADER", action = act.ActivatePaneDirection("Right") }, | |
{ key = "x", mods = "LEADER", action = act.CloseCurrentPane({ confirm = true }) }, | |
{ key = "z", mods = "LEADER", action = act.TogglePaneZoomState }, | |
{ key = "s", mods = "LEADER", action = act.RotatePanes("Clockwise") }, | |
{ key = "s", mods = "LEADER|SHIFT", action = act.RotatePanes("CounterClockwise") }, | |
{ | |
key = "r", | |
mods = "LEADER", | |
action = act.ActivateKeyTable({ name = "resize_pane", one_shot = false }), | |
}, | |
-- Tabs | |
{ key = "t", mods = "LEADER", action = act.SpawnTab("CurrentPaneDomain") }, | |
{ key = "[", mods = "LEADER", action = act.ActivateTabRelative(-1) }, | |
{ key = "]", mods = "LEADER", action = act.ActivateTabRelative(1) }, | |
{ key = "n", mods = "LEADER", action = act.ShowTabNavigator }, | |
{ | |
key = "m", | |
mods = "LEADER", | |
action = act.ActivateKeyTable({ name = "move_tab", one_shot = false }), | |
}, | |
{ | |
key = "e", | |
mods = "LEADER", | |
action = act.PromptInputLine({ | |
description = wezterm.format({ | |
{ Attribute = { Intensity = "Bold" } }, | |
{ Foreground = { AnsiColor = "Fuchsia" } }, | |
{ Text = "Renaming Tab Title...:" }, | |
}), | |
action = wezterm.action_callback(function(window, _, line) | |
if line then | |
window:active_tab():set_title(line) | |
end | |
end), | |
}), | |
}, | |
{ key = "w", mods = "LEADER", action = act.ShowLauncherArgs({ flags = "FUZZY|WORKSPACES" }) }, | |
{ | |
key = "E", | |
mods = "LEADER", | |
action = act.PromptInputLine({ | |
description = wezterm.format({ | |
{ Attribute = { Intensity = "Bold" } }, | |
{ Foreground = { AnsiColor = "Fuchsia" } }, | |
{ Text = "Renaming Workspace...:" }, | |
}), | |
action = wezterm.action_callback(function(_, _, line) | |
if line then | |
wezterm.mux.rename_workspace(wezterm.mux.get_active_workspace(), line) | |
end | |
end), | |
}), | |
}, | |
} | |
config.key_tables = { | |
resize_pane = { | |
{ key = "h", action = act.AdjustPaneSize({ "Left", 1 }) }, | |
{ key = "j", action = act.AdjustPaneSize({ "Down", 1 }) }, | |
{ key = "k", action = act.AdjustPaneSize({ "Up", 1 }) }, | |
{ key = "l", action = act.AdjustPaneSize({ "Right", 1 }) }, | |
{ key = "Escape", action = "PopKeyTable" }, | |
{ key = "Enter", action = "PopKeyTable" }, | |
}, | |
move_tab = { | |
{ key = "h", action = act.MoveTabRelative(-1) }, | |
{ key = "j", action = act.MoveTabRelative(-1) }, | |
{ key = "k", action = act.MoveTabRelative(1) }, | |
{ key = "l", action = act.MoveTabRelative(1) }, | |
{ key = "Escape", action = "PopKeyTable" }, | |
{ key = "Enter", action = "PopKeyTable" }, | |
}, | |
} | |
config.window_padding = { | |
left = 4, | |
right = 4, | |
top = 4, | |
bottom = 4, | |
} | |
config.font_rules = { | |
{ | |
intensity = "Bold", | |
italic = false, | |
font = wezterm.font({ | |
family = "JetBrainsMono Nerd Font", | |
weight = "Bold", | |
}), | |
}, | |
{ | |
italic = true, | |
intensity = "Half", | |
font = wezterm.font({ | |
family = "JetBrainsMono Nerd Font", | |
weight = "DemiBold", | |
style = "Italic", | |
}), | |
}, | |
{ | |
italic = true, | |
intensity = "Bold", | |
font = wezterm.font({ | |
family = "JetBrainsMono Nerd Font", | |
weight = "Bold", | |
style = "Italic", | |
}), | |
}, | |
} | |
config.use_fancy_tab_bar = false | |
config.tab_bar_at_bottom = true | |
config.hide_tab_bar_if_only_one_tab = false | |
config.status_update_interval = 1000 | |
wezterm.on("update-status", function(window, pane) | |
-- Workspace name | |
local stat = window:active_workspace() | |
local stat_color = "#bb9af7" | |
-- It's a little silly to have workspace name all the time | |
-- Utilize this to display LDR or current key table name | |
if window:active_key_table() then | |
stat = window:active_key_table() | |
stat_color = "#7dcfff" | |
end | |
if window:leader_is_active() then | |
stat = "LDR" | |
stat_color = "#88c422" | |
end | |
-- Current working directory | |
-- local basename = function(s) | |
-- -- Nothing a little regex can't fix | |
-- return string.gsub(s, "(.*[/\\])(.*)", "%2") | |
-- end | |
-- CWD and CMD could be nil (e.g. viewing log using Ctrl-Alt-l). Not a big deal, but check in case | |
-- local cwd = pane:get_current_working_dir() | |
-- cwd = cwd and basename(cwd) or "" | |
-- Current command | |
-- local cmd = pane:get_foreground_process_name() | |
-- cmd = cmd and basename(cmd) or "" | |
-- Time | |
-- local time = wezterm.strftime("%H:%M") | |
-- Left status (left of the tab line) | |
window:set_left_status(wezterm.format({ | |
{ Foreground = { Color = stat_color } }, | |
{ Text = " " }, | |
{ Text = wezterm.nerdfonts.oct_table .. " " .. stat }, | |
{ Text = " |" }, | |
})) | |
end) | |
wezterm.on("update-right-status", function(window, pane) | |
-- Current working directory | |
local basename = function(s) | |
return string.gsub(s, "(.*[/\\])(.*)", "%2") | |
end | |
-- CWD and CMD could be nil (e.g. viewing log using Ctrl-Alt-l) | |
local cwd_uri = pane:get_current_working_dir() | |
local cwd = "" | |
if cwd_uri then | |
if type(cwd_uri) == "userdata" then | |
cwd = cwd_uri.file_path | |
end | |
end | |
-- Current command | |
local cmd = pane:get_foreground_process_name() | |
cmd = cmd and basename(cmd) or "" | |
local time = wezterm.strftime("%H:%M") | |
window:set_right_status(wezterm.format({ | |
-- Wezterm has a built-in nerd fonts | |
-- https://wezfurlong.org/wezterm/config/lua/wezterm/nerdfonts.html | |
{ Text = wezterm.nerdfonts.md_folder .. " " .. cwd }, | |
{ Text = " | " }, | |
{ Foreground = { Color = "#e0af68" } }, | |
{ Text = wezterm.nerdfonts.fa_code .. " " .. cmd }, | |
"ResetAttributes", | |
{ Text = " | " }, | |
{ Text = wezterm.nerdfonts.md_clock .. " " .. time }, | |
{ Text = " " }, | |
})) | |
end) | |
config.colors = { | |
cursor_bg = "#c4f036", | |
cursor_fg = "#115511", | |
tab_bar = { | |
background = "#0b0022", | |
active_tab = { | |
bg_color = "#2b2042", | |
fg_color = "#e0e0e0", | |
intensity = "Bold", | |
}, | |
inactive_tab = { | |
bg_color = "#1b1032", | |
fg_color = "#808080", | |
}, | |
inactive_tab_hover = { | |
bg_color = "#2b2042", | |
fg_color = "#c0c0c0", | |
}, | |
new_tab = { | |
bg_color = "#1b1032", | |
fg_color = "#808080", | |
intensity = "Bold", | |
}, | |
new_tab_hover = { | |
bg_color = "#2b2042", | |
fg_color = "#c0c0c0", | |
intensity = "Bold", | |
}, | |
}, | |
} | |
-- Workspaces setup when starting wezterm | |
wezterm.on("gui-startup", function(cmd) | |
local args = {} | |
if cmd then | |
args = cmd.args | |
end | |
--- Artis --- | |
local artis_root = wezterm.home_dir .. "/work/artis/web" | |
local cmd_tab, pane, window = mux.spawn_window({ | |
workspace = "artis", | |
cwd = artis_root, | |
args = args, | |
}) | |
local right_pane = pane:split({ | |
direction = "Right", | |
size = 0.5, | |
cwd = artis_root, | |
}) | |
pane:split({ | |
direction = "Top", | |
size = 0.5, | |
cwd = artis_root .. "/frontend", | |
}) | |
right_pane:split({ | |
direction = "Top", | |
size = 0.5, | |
cwd = artis_root .. "/api", | |
}) | |
cmd_tab:set_title("cmd") | |
local frontend_tab, frontend_pane = window:spawn_tab({ | |
cwd = artis_root .. "/frontend", | |
}) | |
frontend_tab:set_title("frontend") | |
frontend_pane:send_text("TERM=wezterm SKIP=all nvim .\n") | |
local api_tab, api_pane = window:spawn_tab({ | |
cwd = artis_root .. "/api", | |
}) | |
api_tab:set_title("api") | |
api_pane:send_text("TERM=wezterm SKIP=all nvim .\n") | |
--- Home --- | |
local home_root = wezterm.home_dir | |
tab, pane = mux.spawn_window({ | |
workspace = "home", | |
cwd = home_root, | |
args = args, | |
}) | |
mux.set_active_workspace("home") | |
end) | |
return config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment