From 5db7097b94a8a91bd00bde8f83e5b196e12b1479 Mon Sep 17 00:00:00 2001 From: Felipe Silveira Date: Mon, 29 Jul 2024 06:32:09 +0100 Subject: [PATCH] chore(wezterm): small tweaks --- CHANGELOG.md | 3 ++ wezterm/config/appearance.lua | 2 -- wezterm/config/bindings.lua | 54 ++++++++++++++-------------------- wezterm/events/left-status.lua | 2 +- wezterm/events/tab-title.lua | 6 ++-- wezterm/utils/backdrops.lua | 1 - 6 files changed, 29 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fe4bef..5be4c7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ### [2024-07-29] + * [[7484f08]](https://github.com/silveiralexf/.dotfiles/commit/7484f087bb7e733b79eb9f80081749dbaa1cb7f1) chore(docs): readme and spelling updates (silveiralexf@gmail.com) + + * [[7e560cd]](https://github.com/silveiralexf/.dotfiles/commit/7e560cd58a7bc366f2440869fcf78c988369876f) chore(tasks): add dotfile dirs as global vars (silveiralexf@gmail.com) diff --git a/wezterm/config/appearance.lua b/wezterm/config/appearance.lua index 4781508..ef37354 100644 --- a/wezterm/config/appearance.lua +++ b/wezterm/config/appearance.lua @@ -51,8 +51,6 @@ return { window_close_confirmation = 'NeverPrompt', window_frame = { active_titlebar_bg = '#090909', - -- font = fonts.font, - -- font_size = fonts.font_size, }, inactive_pane_hsb = { saturation = 0.9, diff --git a/wezterm/config/bindings.lua b/wezterm/config/bindings.lua index 5586230..2b6821f 100644 --- a/wezterm/config/bindings.lua +++ b/wezterm/config/bindings.lua @@ -4,19 +4,21 @@ local wezterm = require('wezterm') local act = wezterm.action local mod = {} - +local keyboard = {} if platform.is_mac then mod.CMD = 'SUPER' mod.CMD_REV = 'SUPER|SHIFT' mod.CTRL = 'CTRL' mod.CTRL_REV = 'CTRL|SHIFT' mod.LEADER = 'ALT' + keyboard.COMPOSED_KEYS = true -- when curly brackets are opt + shift + 8/9, not ctrl else - mod.CMD = 'ALT' -- to not conflict with other key shortcuts + mod.CMD = 'ALT' -- to avoid conflicting with other key shortcuts mod.CMD_REV = 'ALT|SHIFT' mod.CTRL = 'CTRL' mod.CTRL_REV = 'CTRL|SHIFT' mod.LEADER = 'ALT|CTRL' + keyboard.COMPOSED_KEYS = false end local keys = { @@ -90,7 +92,7 @@ local keys = { -- tabs -- -- tabs: spawn+close { key = 't', mods = mod.CMD, action = act.SpawnTab('DefaultDomain') }, - { key = 'w', mods = mod.LEADER, action = act.CloseCurrentTab({ confirm = false }) }, + { key = 'w', mods = mod.CMD, action = act.CloseCurrentPane({ confirm = false }) }, -- tabs: navigation { key = 'LeftArrow', mods = mod.CMD, action = act.ActivateTabRelative(-1) }, @@ -98,6 +100,20 @@ local keys = { { key = 'LeftArrow', mods = mod.CMD_REV, action = act.MoveTabRelative(-1) }, { key = 'RightArrow', mods = mod.CMD_REV, action = act.MoveTabRelative(1) }, + -- tabs: renaming + { -- TODO: still needs work: formatting, detection, hovering, etc... + key = 'r', + mods = mod.CMD, + action = act.PromptInputLine({ + description = 'Enter new name for tab', + action = wezterm.action_callback(function(window, _, line) + if line then + window:active_tab():set_title(line) + end + end), + }), + }, + -- window -- -- spawn windows { key = 'n', mods = mod.CMD, action = act.SpawnWindow }, @@ -132,35 +148,7 @@ local keys = { }), }, - -- panes -- - -- panes: split panes - { key = 'w', mods = mod.CMD, action = act.CloseCurrentPane({ confirm = false }) }, - { -- TODO: this still needs work - key = 'r', - mods = mod.CMD, - action = act.PromptInputLine({ - description = 'Enter new name for tab', - action = wezterm.action_callback(function(window, _, line) - if line then - window:active_tab():set_title(line) - end - end), - }), - }, - - -- panes: navigation - { key = 'k', mods = mod.LEADER, action = act.ActivatePaneDirection('Up') }, - { key = 'j', mods = mod.LEADER, action = act.ActivatePaneDirection('Down') }, - { key = 'h', mods = mod.LEADER, action = act.ActivatePaneDirection('Left') }, - { key = 'l', mods = mod.LEADER, action = act.ActivatePaneDirection('Right') }, - { - key = 'p', - mods = mod.LEADER, - action = act.PaneSelect({ alphabet = '1234567890', mode = 'SwapWithActiveKeepFocus' }), - }, - - -- key-tables -- - + -- font -- -- font: resize with single stroke { mods = mod.CMD, key = '+', action = act.IncreaseFontSize }, { mods = mod.CMD, key = '-', action = act.DecreaseFontSize }, @@ -201,4 +189,6 @@ return { keys = keys, key_tables = key_tables, mouse_bindings = mouse_bindings, + send_composed_key_when_left_alt_is_pressed = keyboard.COMPOSED_KEYS, + send_composed_key_when_right_alt_is_pressed = keyboard.COMPOSED_KEYS, } diff --git a/wezterm/events/left-status.lua b/wezterm/events/left-status.lua index 007f9de..4e6d613 100644 --- a/wezterm/events/left-status.lua +++ b/wezterm/events/left-status.lua @@ -26,7 +26,7 @@ local _push = function(text, fg, bg) end M.setup = function() - wezterm.on('update-right-status', function(window, _pane) + wezterm.on('update-right-status', function(window, _) __cells__ = {} local name = window:active_key_table() diff --git a/wezterm/events/tab-title.lua b/wezterm/events/tab-title.lua index 8be2da9..b8487e7 100644 --- a/wezterm/events/tab-title.lua +++ b/wezterm/events/tab-title.lua @@ -38,7 +38,7 @@ local _set_tab_idx = function(tabs, tab) return tab_idx end -local _set_title = function(process_name, base_title, max_width, inset, override) +local _set_title = function(process_name, base_title, max_width, inset) local title inset = inset or 6 @@ -77,14 +77,14 @@ local _push = function(bg, fg, attribute, text) end M.setup = function() - wezterm.on('format-tab-title', function(tab, tabs, _panes, _config, hover, max_width) + wezterm.on('format-tab-title', function(tab, tabs, _, _, hover, max_width) __cells__ = {} local bg local fg local process_name = _set_process_name(tab.active_pane.foreground_process_name) local is_admin = _check_if_admin(tab.active_pane.title) - local title = _set_title(process_name, tab.active_pane.title, max_width, (is_admin and 8), _) + local title = _set_title(process_name, tab.active_pane.title, max_width, (is_admin and 8)) local tab_idx = _set_tab_idx(tabs, tab) diff --git a/wezterm/utils/backdrops.lua b/wezterm/utils/backdrops.lua index 61c368e..6cb8f2d 100644 --- a/wezterm/utils/backdrops.lua +++ b/wezterm/utils/backdrops.lua @@ -1,5 +1,4 @@ local colors = require('colors.custom') -local platform = require('utils.platform')() local wezterm = require('wezterm') -- Seeding random numbers before generating for use