diff --git a/wezterm/.config/wezterm/maps.lua b/wezterm/.config/wezterm/maps.lua new file mode 100644 index 0000000..5ffe960 --- /dev/null +++ b/wezterm/.config/wezterm/maps.lua @@ -0,0 +1,78 @@ +local act = require('wezterm').action +local keys = { + { key = 'O', mods = 'CTRL', action = act.ShowDebugOverlay }, + + { -- vertical pane + key = '\\', + mods = 'LEADER', + action = act.SplitHorizontal { domain = 'CurrentPaneDomain' } + }, { -- horizontal pane + key = '-', + mods = 'LEADER', + action = act.SplitVertical { domain = 'CurrentPaneDomain' } + }, { key = 'h', mods = 'CTRL', action = act.ActivatePaneDirection 'Left' }, + { key = 'j', mods = 'CTRL', action = act.ActivatePaneDirection 'Down' }, + { key = 'k', mods = 'CTRL', action = act.ActivatePaneDirection 'Up' }, + { key = 'l', mods = 'CTRL', action = act.ActivatePaneDirection 'Right' }, + { key = 'z', mods = 'LEADER', action = act.TogglePaneZoomState }, + { key = ' ', mods = 'LEADER', action = act.RotatePanes 'Clockwise' }, + { key = 'q', mods = 'LEADER', action = act.PaneSelect { mode = 'Activate' } }, + { + key = 'Q', + mods = 'LEADER', + action = act.PaneSelect { mode = 'SwapWithActive' } + }, { key = 'c', mods = 'LEADER', action = act.SpawnTab 'CurrentPaneDomain' }, + + { key = 't', mods = 'LEADER', action = act.ShowTabNavigator }, + { key = '[', mods = 'LEADER', action = act.ActivateCopyMode }, { + key = 'r', + mods = 'LEADER', + action = act.ActivateKeyTable { + name = 'resize_pane', + one_shot = false, + timeout_milliseconds = 2000 + } + }, { key = 'F', mods = 'LEADER', action = act.QuickSelect }, { + key = '/', + mods = 'LEADER', + action = act.Search('CurrentSelectionOrEmptyString') + }, { + key = 'b', + mods = 'LEADER', + action = act.ActivateKeyTable { name = 'scroll_mode', one_shot = false } + } + +} +-- Leader + number to activate that tab +for i = 1, 8 do + table.insert(keys, { + key = tostring(i), + mods = 'LEADER', + action = act.ActivateTab(i - 1) + }) +end +-- key table sub modes +local key_tables = { + -- mode to change size of any panes + resize_pane = { + { key = 'h', action = act.AdjustPaneSize { 'Left', 1 } }, + { key = 'l', action = act.AdjustPaneSize { 'Right', 1 } }, + { key = 'k', action = act.AdjustPaneSize { 'Up', 1 } }, + { key = 'j', action = act.AdjustPaneSize { 'Down', 1 } }, + { key = 'Escape', action = 'PopKeyTable' } + }, + scroll_mode = { + { key = 'y', mods = 'CTRL', action = act.ScrollByLine(-1) }, + { key = 'e', mods = 'CTRL', action = act.ScrollByLine(1) }, + { key = 'f', mods = 'CTRL', action = act.ScrollByPage(1) }, + { key = 'b', mods = 'CTRL', action = act.ScrollByPage(-1) }, + { key = 'd', mods = 'CTRL', action = act.ScrollByPage(0.5) }, + { key = 'u', mods = 'CTRL', action = act.ScrollByPage(-0.5) }, + { key = 'g', mods = 'CTRL', action = act.ScrollToTop }, + { key = 'G', mods = 'CTRL', action = act.ScrollToBottom }, + { key = '[', mods = 'CTRL', action = act.ScrollToPrompt(-1) }, + { key = ']', mods = 'CTRL', action = act.ScrollToPrompt(1) }, + { key = 'Escape', action = 'PopKeyTable' } + } +} +return { keys = keys, key_tables = key_tables } diff --git a/wezterm/.config/wezterm/wezterm.lua b/wezterm/.config/wezterm/wezterm.lua new file mode 100644 index 0000000..efcafd4 --- /dev/null +++ b/wezterm/.config/wezterm/wezterm.lua @@ -0,0 +1,107 @@ +local wezterm = require 'wezterm' +local mux = wezterm.mux + +local maps = require 'maps' + +-- STATUSBAR +-- show currently active key table in lower right status bar +-- mimicking Vim modes +wezterm.on('update-right-status', function(window, _) + local keytable = window:active_key_table() + if keytable then + keytable = 'MODE: ' .. keytable + else + keytable = '' + end + local workspace = window:active_workspace() + if workspace and workspace ~= 'default' then + workspace = 'WORKSPACE: ' .. workspace + else + workspace = '' + end + + local status = keytable .. ' ' .. workspace + window:set_left_status(status or '') + + -- "Wed Mar 3 08:14" + local date = wezterm.strftime '%a %b %-d %H:%M ' + + local bat = '' + for _, b in ipairs(wezterm.battery_info()) do + bat = + '🔋 ' .. string.format('%.0f%%', b.state_of_charge * 100) .. ' ' .. + b.state + end + + window:set_right_status(wezterm.format {{Text = bat .. ' ' .. date}}) +end) + +wezterm.on("set-up-dotfile-workspace", function(window, pane) + -- Set a workspace for coding on a current project + -- Top pane is for the editor, bottom pane is for the build tool + local project_dir = wezterm.home_dir .. '/projects/test/quarto/quarto-test' + local tab, build_pane, window = mux.spawn_window { + workspace = 'coding', + cwd = project_dir, + args = args + } + local editor_pane = build_pane:split{ + direction = 'Top', + size = 0.6, + cwd = project_dir + } + build_pane:send_text 'quarto check' + mux.set_active_workspace 'coding' +end) +-- +-- wezterm.on('gui-startup', function(cmd) +-- -- allow `wezterm start -- something` to affect what we spawn +-- -- in our initial window +-- local args = {} +-- if cmd then args = cmd.args end +-- +-- -- Set a workspace for coding on a current project +-- -- Top pane is for the editor, bottom pane is for the build tool +-- local project_dir = wezterm.home_dir .. '/projects/test/quarto/quarto-test' +-- local tab, build_pane, window = mux.spawn_window { +-- workspace = 'coding', +-- cwd = project_dir, +-- args = args +-- } +-- local editor_pane = build_pane:split { +-- direction = 'Top', +-- size = 0.6, +-- cwd = project_dir +-- } +-- build_pane:send_text 'quarto check' +-- +-- -- A workspace for interacting with a local machine that +-- -- runs some docker containners for home automation +-- local tab, pane, window = mux.spawn_window { +-- workspace = 'toppy', +-- args = { 'top' } +-- } +-- +-- -- We want to startup in the coding workspace +-- mux.set_active_workspace 'coding' +-- end) + +return { + enable_wayland = true, + + hide_tab_bar_if_only_one_tab = true, + use_fancy_tab_bar = false, + tab_bar_at_bottom = true, + window_padding = {left = 0, right = 0, top = 0, bottom = 0}, + + color_scheme = "Nord (base16)", + -- default_prog = {"nu"}, + scrollback_lines = 10000, + + font = wezterm.font('Liga Iosevka'), + line_height = 1.0, + + leader = {key = 'a', mods = 'CTRL', timeout_milliseconds = 1500}, + keys = maps.keys, + key_tables = maps.key_tables +}