local wezterm = require 'wezterm' local config = wezterm.config_builder() local act = wezterm.action local io = require 'io' local os = require 'os' -- config.default_prog = { 'fish', '-l' } wezterm.on('trigger-emacs-with-scrollback', function(window, pane) -- Retrieve the text from the pane local text = pane:get_lines_as_text(pane:get_dimensions().scrollback_rows) -- Create a temporary file to pass to vim local name = os.tmpname() local f = io.open(name, 'w+') f:write(text) f:flush() f:close() -- Open a new window running vim and tell it to open the file window:perform_action( act.SpawnCommandInNewWindow { args = { 'em', name }, }, pane ) -- Wait "enough" time for vim to read the file before we remove it. -- The window creation and process spawn are asynchronous wrt. running -- this script and are not awaitable, so we just pick a number. -- -- Note: We don't strictly need to remove this file, but it is nice -- to avoid cluttering up the temporary directory. wezterm.sleep_ms(1000) os.remove(name) end) -- plugins local domains = wezterm.plugin.require("https://github.com/DavidRR-F/quick_domains.wezterm") local tabline = wezterm.plugin.require("https://github.com/michaelbrusegard/tabline.wez") local workspace_switcher = wezterm.plugin.require("https://github.com/MLFlexer/smart_workspace_switcher.wezterm") config.enable_wayland = false; -- config.front_end = "WebGpu"; config.font_size = 14 config.font = wezterm.font { family = 'JetBrains Mono', weight = 'Medium' } -- config.enable_scroll_bar = true config.color_scheme = 'Adventure' config.colors = { background = "#111111", tab_bar = { background = "#111111", inactive_tab = { fg_color = "#444444", bg_color = "#111111" } } } config.background = { { source = { Color = '#111111' }, width = "100%", height = "100%", opacity = 1 } } config.window_decorations = "RESIZE" config.window_padding = { left = 12, right = 12, top = 6, bottom = 6, } config.cursor_thickness = 2 config.default_cursor_style = 'SteadyBar' config.use_fancy_tab_bar = false config.tab_bar_at_bottom = true config.enable_kitty_keyboard = true config.unzoom_on_switch_pane = true config.keys = { { key = 'Enter', mods = 'CTRL', action = act.SplitVertical { domain = 'CurrentPaneDomain' }, }, { key = 'Enter', mods = 'CTRL|SHIFT', action = act.SplitHorizontal { domain = 'CurrentPaneDomain' }, }, { key = 'w', mods = 'CTRL', action = wezterm.action.CloseCurrentTab { confirm = true }, }, { key = 'w', mods = 'CTRL|SHIFT', action = act.DetachDomain 'CurrentPaneDomain', }, { key = 'k', mods = 'CTRL|SHIFT', action = act.Multiple { act.ClearScrollback 'ScrollbackAndViewport', act.SendKey { key = 'L', mods = 'CTRL' }, }, }, { key = 'z', mods = 'CTRL|META', action = wezterm.action.TogglePaneZoomState, }, { key = 'E', mods = 'CTRL', action = act.EmitEvent 'trigger-emacs-with-scrollback', }, { key = 'o', mods = 'CTRL', action = wezterm.action.ShowLauncher }, { key="Backspace", mods="CTRL", action=act.SendKey { key="Backspace", mods="META" } }, { key='t', mods='CTRL', action=act { SpawnCommandInNewTab = { cwd = wezterm.home_dir } } }, { key="LeftArrow", mods="CTRL|META", action=act.ActivateTabRelative(-1) }, { key="RightArrow", mods="CTRL|META", action=act.ActivateTabRelative(1) }, { key="UpArrow", mods="CTRL|META", action=act.ActivatePaneDirection("Prev") }, { key="DownArrow", mods="CTRL|META", action=act.ActivatePaneDirection("Next") }, { key='h', mods='CTRL|META', action=wezterm.action{ActivatePaneDirection="Left"} }, { key='l', mods='CTRL|META', action=wezterm.action{ActivatePaneDirection="Right"} }, { key='j', mods='CTRL|META', action=wezterm.action{ActivatePaneDirection="Up"} }, { key='k', mods='CTRL|META', action=wezterm.action{ActivatePaneDirection="Down"} }, } tabline.setup({ options = { theme = 'Adventure', theme_overrides = { background = "#111111", tab = { active = { fg = '#eeeeee', bg = '#111111' }, inactive = { fg = '#999999', bg = '#111111' }, inactive_hover = { fg = '#cccccc', bg = '#111111' }, }, normal_mode = { a = { bg = "#333333", fg = "#eeeeee" }, b = { bg = "#111111", fg = "#eeeeee" }, c = { bg = "#111111", fg = "#eeeeee" }, x = { bg = "#111111", fg = "#eeeeee" }, y = { bg = "#111111", fg = "#eeeeee" }, z = { bg = "#333333", fg = "#eeeeee" }, }, copy_mode = { b = { bg = "#222222", fg = "#eeeeee" } } }, section_separators = { left = wezterm.nerdfonts.ple_right_half_circle_thick, right = wezterm.nerdfonts.ple_left_half_circle_thick, }, component_separators = { left = wezterm.nerdfonts.ple_right_half_circle_thin, right = wezterm.nerdfonts.ple_left_half_circle_thin, }, tab_separators = { left = wezterm.nerdfonts.ple_right_half_circle_thick, right = wezterm.nerdfonts.ple_left_half_circle_thick, }, icons_enabled = true, tabs_enabled = true, }, sections = { tabline_a = { 'workspace' }, tabline_b = { '' }, tabline_c = { '' }, tab_active = { 'index', { 'process', icons_only = true, process_to_icon = { ['fish'] = wezterm.nerdfonts.cod_terminal } }, { 'parent', padding = 0 }, '/', { 'cwd', padding = { left = 0, right = 1 } }, { 'zoomed', padding = 0 }, }, tab_inactive = { 'index', { 'process', process_to_icon = { ['fish'] = wezterm.nerdfonts.cod_terminal } }, { 'parent', padding = 0 }, '/', { 'cwd', padding = { left = 0, right = 1 } }, { 'zoomed', padding = 0 }, }, tabline_x = { '' }, tabline_y = { '' }, tabline_z = { 'domain' }, }, extensions = { smart_workspace_switcher, quick_domains }, }) tabline.apply_to_config(config) domains.apply_to_config( config, { keys = { -- open domain in new tab attach = { -- mod keys for fuzzy domain finder mods = 'CTRL|SHIFT', -- base key for fuzzy domain finder key = 'a', -- key table to insert key map to if any tbl = '', }, -- open domain in split pane -- excludes remote domains -- add remote domains as exec domain for split binds vsplit = { key = 'v', mods = 'CTRL', tbl = 'tmux' }, hsplit = { key = 'h', mods = 'CTRL', tbl = 'tmux' } }, auto = { ssh_ignore = false, exec_ignore = { ssh = false } } } ) workspace_switcher.apply_to_config(config) return config