dotfiles/terminal/.config/wezterm/maps.lua

145 lines
4.7 KiB
Lua
Raw Normal View History

2023-06-15 08:12:30 +00:00
local wezterm = require("wezterm")
2022-11-25 15:21:20 +00:00
local act = wezterm.action
2022-11-16 17:29:02 +00:00
local keys = {
2023-06-15 08:12:30 +00:00
{ key = "O", mods = "CTRL", action = act.ShowDebugOverlay },
{ key = "[", mods = "CTRL", action = act.ScrollToPrompt(-1) },
{ key = "]", mods = "CTRL", action = act.ScrollToPrompt(1) },
{ -- vertical pane
key = "\\",
mods = "LEADER",
action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }),
},
{ -- horizontal pane
key = "-",
mods = "LEADER",
action = act.SplitVertical({ domain = "CurrentPaneDomain" }),
}, -- pane movement keys
{
key = "h",
mods = "CTRL",
action = act.EmitEvent("ActivatePaneDirection-left"),
},
{
key = "j",
mods = "CTRL",
action = act.EmitEvent("ActivatePaneDirection-down"),
},
{
key = "k",
mods = "CTRL",
action = act.EmitEvent("ActivatePaneDirection-up"),
},
{
key = "l",
mods = "CTRL",
action = act.EmitEvent("ActivatePaneDirection-right"),
},
{ key = "p", mods = "LEADER", action = act.ActivatePaneDirection("Prev") },
{ key = "x", mods = "LEADER", action = act.CloseCurrentPane({ confirm = false }) },
2023-06-15 08:12:30 +00:00
{ 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 = "SwapWithActiveKeepFocus" }),
},
{
key = "q",
mods = "LEADER|CTRL",
action = act.PaneSelect({ mode = "MoveToNewTab" }),
2023-06-15 08:12:30 +00:00
},
{ key = "c", mods = "LEADER", action = act.SpawnTab("CurrentPaneDomain") },
{ key = ",", mods = "LEADER", action = act.ActivateTabRelative(-1) },
{ key = ".", mods = "LEADER", action = act.ActivateTabRelative(1) }, -- workspace selection
{ key = "<", mods = "LEADER|SHIFT", action = act.MoveTabRelative(-1) },
{ key = ">", mods = "LEADER|SHIFT", action = act.MoveTabRelative(1) }, -- workspace selection
2023-06-15 08:12:30 +00:00
{
key = "s",
mods = "LEADER",
action = act.ShowLauncherArgs({ flags = "FUZZY|WORKSPACES" }),
},
{ key = "T", mods = "LEADER", action = act.ShowTabNavigator },
2023-06-15 08:12:30 +00:00
{ key = "[", mods = "LEADER", action = act.ActivateCopyMode },
{
key = "r",
mods = "LEADER",
action = act.ActivateKeyTable({
name = "resize_pane",
one_shot = false,
timeout_milliseconds = 2000,
replace_current = true,
}),
},
{ key = "f", mods = "LEADER", action = act.QuickSelect },
-- open web link
2023-06-15 08:12:30 +00:00
{
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 = "b",
mods = "LEADER",
action = act.ActivateKeyTable({
name = "scroll_mode",
one_shot = false,
replace_current = true,
timeout_milliseconds = 15000,
}),
},
{ key = "e", mods = "LEADER", action = act.EmitEvent("edit-scrollback") },
{ key = "a", mods = "CTRL|ALT", action = act.EmitEvent("toggle-leader") },
{ key = "t", mods = "LEADER", action = act.EmitEvent("toggle-tabbar") },
{ key = "Enter", mods = "CTRL", action = wezterm.action({ SendString = "\x1b[13;5u" }) },
{ key = "Enter", mods = "SHIFT", action = wezterm.action({ SendString = "\x1b[13;2u" }) },
2022-11-16 17:29:02 +00:00
}
-- Leader + number to activate that tab
for i = 1, 8 do
2023-06-15 08:12:30 +00:00
table.insert(keys, {
key = tostring(i),
mods = "LEADER",
action = act.ActivateTab(i - 1),
})
2022-11-16 17:29:02 +00:00
end
-- key table sub modes
local key_tables = {
2023-06-15 08:12:30 +00:00
-- 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 = "H", action = act.AdjustPaneSize({ "Left", 10 }) },
{ key = "L", action = act.AdjustPaneSize({ "Right", 10 }) },
{ key = "K", action = act.AdjustPaneSize({ "Up", 10 }) },
{ key = "J", action = act.AdjustPaneSize({ "Down", 10 }) },
{ 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 = "Escape", action = "PopKeyTable" },
},
2022-11-16 17:29:02 +00:00
}
return { keys = keys, key_tables = key_tables }