From d3d13b3083f55a26e4fefb8f0ec353620cf277b2 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 10 Jan 2023 13:50:35 +0100 Subject: [PATCH] wezterm: Add url-opening to quickselect Added new quickselect mode to quickly open a displayed url. Changed original quickselect to use leader-f mapping (instead of shift+f) and made new mode callable through the shift+f version. from: https://github.com/wez/wezterm/issues/1362 Delegated scroll mode invocation to leader-b, as in original setup. --- terminal/.config/wezterm/maps.lua | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/terminal/.config/wezterm/maps.lua b/terminal/.config/wezterm/maps.lua index 78c9e13..5c65624 100644 --- a/terminal/.config/wezterm/maps.lua +++ b/terminal/.config/wezterm/maps.lua @@ -57,25 +57,37 @@ local keys = { timeout_milliseconds = 2000, replace_current = true } - }, { key = 'F', mods = 'LEADER', action = act.QuickSelect }, { + }, { key = 'f', mods = 'LEADER', action = act.QuickSelect }, { + key = 'F', + mods = 'LEADER', + action = wezterm.action.QuickSelectArgs { + patterns = { "https?://\\S+" }, + action = wezterm.action_callback( + function(window, pane) + local url = window:get_selection_text_for_pane(pane) + wezterm.log_info("opening: " .. url) + wezterm.open_with(url) + end) + } + }, { key = '/', mods = 'LEADER', action = act.Search('CurrentSelectionOrEmptyString') }, { - key = 'f', + key = 'b', mods = 'LEADER', action = act.ActivateKeyTable { name = 'scroll_mode', one_shot = false, replace_current = true, - timeout_milliseconds = 15000, + timeout_milliseconds = 15000 } - }, { key = 'e', mods = 'LEADER', action = act.EmitEvent 'edit-scrollback' }, { + }, { key = 'e', mods = 'LEADER', action = act.EmitEvent 'edit-scrollback' }, + { key = 'l', mods = 'LEADER', action = act.EmitEvent 'ActivatePaneDirection-Right' - }, - { key = 'a', mods = 'CTRL|ALT', action = act.EmitEvent 'toggle-leader' } + }, { key = 'a', mods = 'CTRL|ALT', action = act.EmitEvent 'toggle-leader' } } -- Leader + number to activate that tab @@ -110,6 +122,6 @@ local key_tables = { { key = 'g', mods = 'CTRL', action = act.ScrollToTop }, { key = 'G', mods = 'CTRL', action = act.ScrollToBottom }, { key = 'Escape', action = 'PopKeyTable' } - }, + } } return { keys = keys, key_tables = key_tables }