Not for normies
| 1 | local wezterm = require("wezterm") |
| 2 | local utils = require("utils") |
| 3 | local act = wezterm.action |
| 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() |
| 16 | |
| 17 | -- window config |
| 18 | config.enable_wayland = false |
| 19 | config.font_size = 8 |
| 20 | config.window_decorations = "RESIZE" |
| 21 | config.window_background_opacity = 0.85 |
| 22 | config.enable_scroll_bar = true |
| 23 | config.colors = { |
| 24 | scrollbar_thumb = "orange", |
| 25 | } |
| 26 | config.color_scheme = "Tokyo Night Storm" |
| 27 | |
| 28 | -- keymap |
| 29 | config.keys = { |
| 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") }, |
| 35 | |
| 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 }) }, |
| 41 | |
| 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" }) }, |
| 47 | |
| 48 | -- New tab in current pane's cwd |
| 49 | { key = "t", mods = "SHIFT|ALT", action = act.SpawnTab("CurrentPaneDomain") }, |
| 50 | |
| 51 | -- Close current pane |
| 52 | { key = "q", mods = "ALT", action = act.CloseCurrentPane({ confirm = true }) }, |
| 53 | |
| 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 | }, |
| 63 | |
| 64 | -- workspace switcher |
| 65 | { |
| 66 | key = "p", |
| 67 | mods = "ALT", |
| 68 | action = workspace_switcher.switch_to_prev_workspace(), |
| 69 | }, |
| 70 | |
| 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 | }, |
| 123 | } |
| 124 | |
| 125 | return config |