Not for normies
chore: tried wezterm again, feels slow
1 file changed, +99 -79
+99-79wezterm/wezterm.lua
| @@ -2,104 +2,124 @@ local wezterm = require("wezterm") | ||
| 2 | 2 | local utils = require("utils") |
| 3 | 3 | local act = wezterm.action |
| 4 | 4 | local config = wezterm.config_builder() |
| 5 | +local resurrect = wezterm.plugin.require("https://github.com/MLFlexer/resurrect.wezterm") | |
| 6 | +local tabline = wezterm.plugin.require("https://github.com/michaelbrusegard/tabline.wez") | |
| 7 | +local workspace_switcher = wezterm.plugin.require("https://github.com/MLFlexer/smart_workspace_switcher.wezterm") | |
| 8 | + | |
| 9 | +-- set up tabline | |
| 10 | +tabline.setup() | |
| 11 | +tabline.apply_to_config(config) | |
| 12 | + | |
| 13 | +-- set up resurrect | |
| 14 | +wezterm.on("gui-startup", resurrect.state_manager.resurrect_on_gui_startup) | |
| 15 | +resurrect.state_manager.periodic_save() | |
| 5 | 16 | |
| 6 | 17 | -- window config |
| 7 | 18 | config.enable_wayland = false |
| 8 | -config.font_size = 10 | |
| 19 | +config.font_size = 8 | |
| 9 | 20 | config.window_decorations = "RESIZE" |
| 10 | 21 | config.window_background_opacity = 0.85 |
| 11 | 22 | config.enable_scroll_bar = true |
| 12 | 23 | config.colors = { |
| 13 | - scrollbar_thumb = "grey", | |
| 24 | + scrollbar_thumb = "orange", | |
| 14 | 25 | } |
| 15 | 26 | config.color_scheme = "Tokyo Night Storm" |
| 16 | 27 | |
| 17 | 28 | -- keymap |
| 18 | 29 | config.keys = { |
| 19 | - -- Vim like pane movement | |
| 20 | - { key = "h", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Left") }, | |
| 21 | - { key = "j", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Down") }, | |
| 22 | - { key = "k", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Up") }, | |
| 23 | - { key = "l", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Right") }, | |
| 24 | - | |
| 25 | - -- Vim like resize events | |
| 26 | - { key = "h", mods = "CTRL|SHIFT|ALT", action = act.AdjustPaneSize({ "Left", 3 }) }, | |
| 27 | - { key = "j", mods = "CTRL|SHIFT|ALT", action = act.AdjustPaneSize({ "Down", 3 }) }, | |
| 28 | - { key = "k", mods = "CTRL|SHIFT|ALT", action = act.AdjustPaneSize({ "Up", 3 }) }, | |
| 29 | - { key = "l", mods = "CTRL|SHIFT|ALT", action = act.AdjustPaneSize({ "Right", 3 }) }, | |
| 30 | + -- Vim like pane movement | |
| 31 | + { key = "h", mods = "ALT", action = act.ActivatePaneDirection("Left") }, | |
| 32 | + { key = "j", mods = "ALT", action = act.ActivatePaneDirection("Down") }, | |
| 33 | + { key = "k", mods = "ALT", action = act.ActivatePaneDirection("Up") }, | |
| 34 | + { key = "l", mods = "ALT", action = act.ActivatePaneDirection("Right") }, | |
| 30 | 35 | |
| 31 | - -- make ctrl-enter mean something | |
| 32 | - { key = "Enter", mods = "CTRL", action = wezterm.action.SendString("\x1bo") }, | |
| 36 | + -- Vim like resize events | |
| 37 | + { key = "h", mods = "SHIFT|ALT", action = act.AdjustPaneSize({ "Left", 3 }) }, | |
| 38 | + { key = "j", mods = "SHIFT|ALT", action = act.AdjustPaneSize({ "Down", 3 }) }, | |
| 39 | + { key = "k", mods = "SHIFT|ALT", action = act.AdjustPaneSize({ "Up", 3 }) }, | |
| 40 | + { key = "l", mods = "SHIFT|ALT", action = act.AdjustPaneSize({ "Right", 3 }) }, | |
| 33 | 41 | |
| 34 | - -- Exit pane | |
| 35 | - { key = "e", mods = "CTRL|SHIFT", action = act.CloseCurrentPane({ confirm = false }) }, | |
| 42 | + -- Vim like create panes | |
| 43 | + { key = "h", mods = "CTRL|SHIFT", action = act.SplitPane({ direction = "Left" }) }, | |
| 44 | + { key = "j", mods = "CTRL|SHIFT", action = act.SplitPane({ direction = "Down" }) }, | |
| 45 | + { key = "k", mods = "CTRL|SHIFT", action = act.SplitPane({ direction = "Up" }) }, | |
| 46 | + { key = "l", mods = "CTRL|SHIFT", action = act.SplitPane({ direction = "Right" }) }, | |
| 36 | 47 | |
| 37 | - -- window keys | |
| 38 | - { key = "n", mods = "CTRL|ALT", action = utils.SpawnMaximizedCommandInNewWindow({}) }, | |
| 48 | + -- New tab in current pane's cwd | |
| 49 | + { key = "t", mods = "SHIFT|ALT", action = act.SpawnTab("CurrentPaneDomain") }, | |
| 39 | 50 | |
| 40 | - -- debug | |
| 41 | - { key = "d", mods = "CTRL|SHIFT", action = act.ShowDebugOverlay }, | |
| 51 | + -- Close current pane | |
| 52 | + { key = "q", mods = "ALT", action = act.CloseCurrentPane({ confirm = true }) }, | |
| 42 | 53 | |
| 43 | - -- quit all | |
| 44 | - { key = "q", mods = "CTRL|SHIFT", action = act.QuitApplication }, | |
| 54 | + -- open lazygit | |
| 55 | + { | |
| 56 | + key = "g", | |
| 57 | + mods = "CTRL|SHIFT", | |
| 58 | + action = wezterm.action_callback(function(win, pane) | |
| 59 | + win:perform_action(act.SplitPane({ direction = "Right", command = { args = { "lazygit" } } }), pane) | |
| 60 | + win:perform_action(act.TogglePaneZoomState, pane) | |
| 61 | + end), | |
| 62 | + }, | |
| 45 | 63 | |
| 46 | - -- Show the launcher in fuzzy selection mode and have it list all workspaces | |
| 47 | - -- and allow activating one. | |
| 48 | - { | |
| 49 | - key = "9", | |
| 50 | - mods = "ALT", | |
| 51 | - action = act.ShowLauncherArgs({ | |
| 52 | - flags = "FUZZY|WORKSPACES", | |
| 53 | - }), | |
| 54 | - }, | |
| 55 | - { key = "n", mods = "ALT", action = act.SwitchWorkspaceRelative(1) }, | |
| 56 | - { key = "p", mods = "ALT", action = act.SwitchWorkspaceRelative(-1) }, | |
| 57 | - -- Prompt for a name to use for a new workspace and switch to it. | |
| 58 | - { | |
| 59 | - key = "w", | |
| 60 | - mods = "CTRL|SHIFT", | |
| 61 | - action = act.PromptInputLine({ | |
| 62 | - description = wezterm.format({ | |
| 63 | - { Attribute = { Intensity = "Bold" } }, | |
| 64 | - { Foreground = { AnsiColor = "Fuchsia" } }, | |
| 65 | - { Text = "Enter name for new workspace" }, | |
| 66 | - }), | |
| 67 | - action = wezterm.action_callback(function(window, pane, line) | |
| 68 | - -- line will be `nil` if they hit escape without entering anything | |
| 69 | - -- An empty string if they just hit enter | |
| 70 | - -- Or the actual line of text they wrote | |
| 71 | - if line then | |
| 72 | - window:perform_action( | |
| 73 | - act.SwitchToWorkspace({ | |
| 74 | - name = line, | |
| 75 | - }), | |
| 76 | - pane | |
| 77 | - ) | |
| 78 | - end | |
| 79 | - end), | |
| 80 | - }), | |
| 81 | - }, | |
| 64 | + -- workspace switcher | |
| 65 | + { | |
| 66 | + key = "p", | |
| 67 | + mods = "ALT", | |
| 68 | + action = workspace_switcher.switch_to_prev_workspace(), | |
| 69 | + }, | |
| 82 | 70 | |
| 83 | - -- open lazygit | |
| 84 | - { | |
| 85 | - key = "g", | |
| 86 | - mods = "CTRL|SHIFT", | |
| 87 | - action = utils.SpawnMaximizedCommandInNewWindow({ "lazygit" }), | |
| 88 | - }, | |
| 71 | + -- resurrect bindings | |
| 72 | + { | |
| 73 | + key = "w", | |
| 74 | + mods = "ALT", | |
| 75 | + action = wezterm.action_callback(function(win, pane) | |
| 76 | + resurrect.state_manager.save_state(resurrect.workspace_state.get_workspace_state()) | |
| 77 | + end), | |
| 78 | + }, | |
| 79 | + { | |
| 80 | + key = "W", | |
| 81 | + mods = "ALT", | |
| 82 | + action = resurrect.window_state.save_window_action(), | |
| 83 | + }, | |
| 84 | + { | |
| 85 | + key = "T", | |
| 86 | + mods = "ALT", | |
| 87 | + action = resurrect.tab_state.save_tab_action(), | |
| 88 | + }, | |
| 89 | + { | |
| 90 | + key = "s", | |
| 91 | + mods = "ALT", | |
| 92 | + action = wezterm.action_callback(function(win, pane) | |
| 93 | + resurrect.state_manager.save_state(resurrect.workspace_state.get_workspace_state()) | |
| 94 | + resurrect.window_state.save_window_action() | |
| 95 | + end), | |
| 96 | + }, | |
| 97 | + { | |
| 98 | + key = "r", | |
| 99 | + mods = "ALT", | |
| 100 | + action = wezterm.action_callback(function(win, pane) | |
| 101 | + resurrect.fuzzy_loader.fuzzy_load(win, pane, function(id, label) | |
| 102 | + local type = string.match(id, "^([^/]+)") -- match before '/' | |
| 103 | + id = string.match(id, "([^/]+)$") -- match after '/' | |
| 104 | + id = string.match(id, "(.+)%..+$") -- remove file extention | |
| 105 | + local opts = { | |
| 106 | + relative = true, | |
| 107 | + restore_text = true, | |
| 108 | + on_pane_restore = resurrect.tab_state.default_on_pane_restore, | |
| 109 | + } | |
| 110 | + if type == "workspace" then | |
| 111 | + local state = resurrect.state_manager.load_state(id, "workspace") | |
| 112 | + resurrect.workspace_state.restore_workspace(state, opts) | |
| 113 | + elseif type == "window" then | |
| 114 | + local state = resurrect.state_manager.load_state(id, "window") | |
| 115 | + resurrect.window_state.restore_window(pane:window(), state, opts) | |
| 116 | + elseif type == "tab" then | |
| 117 | + local state = resurrect.state_manager.load_state(id, "tab") | |
| 118 | + resurrect.tab_state.restore_tab(pane:tab(), state, opts) | |
| 119 | + end | |
| 120 | + end) | |
| 121 | + end), | |
| 122 | + }, | |
| 89 | 123 | } |
| 90 | 124 | |
| 91 | --- plugins | |
| 92 | -local tabline = wezterm.plugin.require("https://github.com/michaelbrusegard/tabline.wez") | |
| 93 | -tabline.setup() | |
| 94 | -tabline.apply_to_config(config) | |
| 95 | - | |
| 96 | --- log success on reload | |
| 97 | -wezterm.on("window-config-reloaded", function(_, _) | |
| 98 | - wezterm.log_info("Successfully loaded config from .config") | |
| 99 | -end) | |
| 100 | - | |
| 101 | --- load workspaces | |
| 102 | -local workspaces = require("workspaces") | |
| 103 | -workspaces.setup(config) | |
| 104 | - | |
| 105 | 125 | return config |