refactor(wezterm): better keybind format
This commit is contained in:
parent
b2e7df6e04
commit
91cd369dca
2 changed files with 92 additions and 194 deletions
|
@ -1,190 +1,89 @@
|
|||
local wezterm = require("wezterm")
|
||||
local act = wezterm.action
|
||||
|
||||
return {
|
||||
-- use 'Backslash' to split horizontally
|
||||
{
|
||||
key = "\\",
|
||||
mods = "LEADER",
|
||||
action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }),
|
||||
},
|
||||
-- and 'Minus' to split vertically
|
||||
{
|
||||
key = "-",
|
||||
mods = "LEADER",
|
||||
action = act.SplitVertical({ domain = "CurrentPaneDomain" }),
|
||||
},
|
||||
-- 'hjkl' to move between panes
|
||||
{ key = "h", mods = "LEADER", action = act.ActivatePaneDirection("Left") },
|
||||
{ key = "j", mods = "LEADER", action = act.ActivatePaneDirection("Down") },
|
||||
{ key = "k", mods = "LEADER", action = act.ActivatePaneDirection("Up") },
|
||||
{ key = "l", mods = "LEADER", action = act.ActivatePaneDirection("Right") },
|
||||
-- -- Shift + 'hjkl' to resize panes
|
||||
{
|
||||
key = "h",
|
||||
mods = "LEADER|SHIFT",
|
||||
action = act.AdjustPaneSize({ "Left", 5 }),
|
||||
},
|
||||
{
|
||||
key = "j",
|
||||
mods = "LEADER|SHIFT",
|
||||
action = act.AdjustPaneSize({ "Down", 5 }),
|
||||
},
|
||||
{
|
||||
key = "k",
|
||||
mods = "LEADER|SHIFT",
|
||||
action = act.AdjustPaneSize({ "Up", 5 }),
|
||||
},
|
||||
{
|
||||
key = "l",
|
||||
mods = "LEADER|SHIFT",
|
||||
action = act.AdjustPaneSize({ "Right", 5 }),
|
||||
},
|
||||
-- numbers to navigate to tabs
|
||||
{ key = "1", mods = "LEADER", action = act.ActivateTab(0) },
|
||||
{ key = "2", mods = "LEADER", action = act.ActivateTab(1) },
|
||||
{ key = "3", mods = "LEADER", action = act.ActivateTab(2) },
|
||||
{ key = "4", mods = "LEADER", action = act.ActivateTab(3) },
|
||||
{ key = "5", mods = "LEADER", action = act.ActivateTab(4) },
|
||||
{ key = "6", mods = "LEADER", action = act.ActivateTab(5) },
|
||||
{ key = "7", mods = "LEADER", action = act.ActivateTab(6) },
|
||||
{ key = "8", mods = "LEADER", action = act.ActivateTab(7) },
|
||||
{ key = "9", mods = "LEADER", action = act.ActivateTab(8) },
|
||||
{ key = "9", mods = "LEADER", action = act.ActivateTab(9) },
|
||||
{ key = "0", mods = "LEADER", action = act.ActivateTab(-1) },
|
||||
{ key = "1", mods = "SUPER", action = act.ActivateTab(0) },
|
||||
{ key = "2", mods = "SUPER", action = act.ActivateTab(1) },
|
||||
{ key = "3", mods = "SUPER", action = act.ActivateTab(2) },
|
||||
{ key = "4", mods = "SUPER", action = act.ActivateTab(3) },
|
||||
{ key = "5", mods = "SUPER", action = act.ActivateTab(4) },
|
||||
{ key = "6", mods = "SUPER", action = act.ActivateTab(5) },
|
||||
{ key = "7", mods = "SUPER", action = act.ActivateTab(6) },
|
||||
{ key = "8", mods = "SUPER", action = act.ActivateTab(7) },
|
||||
{ key = "9", mods = "SUPER", action = act.ActivateTab(8) },
|
||||
{ key = "9", mods = "SUPER", action = act.ActivateTab(9) },
|
||||
{ key = "0", mods = "SUPER", action = act.ActivateTab(-1) },
|
||||
-- 'c' to create a new tab
|
||||
{ key = "c", mods = "LEADER", action = act.SpawnTab("CurrentPaneDomain") },
|
||||
-- 'x' to kill the current pane
|
||||
{
|
||||
key = "x",
|
||||
mods = "LEADER",
|
||||
action = act.CloseCurrentPane({ confirm = true }),
|
||||
},
|
||||
-- 'z' to toggle the zoom for the current pane
|
||||
{ key = "z", mods = "LEADER", action = "TogglePaneZoomState" },
|
||||
-- 'Z' to hide the tab bar (useful for screenshots)
|
||||
{
|
||||
key = "Z",
|
||||
mods = "LEADER",
|
||||
action = wezterm.action_callback(function(window)
|
||||
local shortcuts = {}
|
||||
|
||||
local map = function(key, mods, action)
|
||||
if type(mods) == "string" then
|
||||
table.insert(shortcuts, { key = key, mods = mods, action = action })
|
||||
elseif type(mods) == "table" then
|
||||
for _, mod in pairs(mods) do
|
||||
table.insert(shortcuts, { key = key, mods = mod, action = action })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local toggleTabBar = wezterm.action_callback(function(window)
|
||||
wezterm.GLOBAL.enable_tab_bar = not wezterm.GLOBAL.enable_tab_bar
|
||||
window:set_config_overrides({
|
||||
enable_tab_bar = wezterm.GLOBAL.enable_tab_bar,
|
||||
})
|
||||
end),
|
||||
},
|
||||
-- 'v' to visually select in the current pane
|
||||
{ key = "v", mods = "LEADER", action = "ActivateCopyMode" },
|
||||
-- 'r' to rotate panes
|
||||
{ key = "r", mods = "LEADER", action = act.RotatePanes("Clockwise") },
|
||||
{ key = " ", mods = "LEADER", action = act.QuickSelect },
|
||||
{
|
||||
key = "o",
|
||||
mods = "LEADER",
|
||||
action = act.QuickSelectArgs({
|
||||
end)
|
||||
|
||||
local openUrl = act.QuickSelectArgs({
|
||||
label = "open url",
|
||||
patterns = {
|
||||
"https?://\\S+",
|
||||
},
|
||||
patterns = { "https?://\\S+" },
|
||||
action = wezterm.action_callback(function(window, pane)
|
||||
local url = window:get_selection_text_for_pane(pane)
|
||||
wezterm.open_with(url)
|
||||
end),
|
||||
}),
|
||||
},
|
||||
-- copypasta
|
||||
{ key = "Enter", mods = "ALT", action = act.ToggleFullScreen },
|
||||
})
|
||||
|
||||
{ key = "-", mods = "CTRL", action = act.DecreaseFontSize },
|
||||
{ key = "-", mods = "SUPER", action = act.DecreaseFontSize },
|
||||
{ key = "=", mods = "CTRL", action = act.IncreaseFontSize },
|
||||
{ key = "=", mods = "SUPER", action = act.IncreaseFontSize },
|
||||
{ key = "0", mods = "CTRL", action = act.ResetFontSize },
|
||||
{ key = "0", mods = "SUPER", action = act.ResetFontSize },
|
||||
-- use 'Backslash' to split horizontally
|
||||
map("\\", "LEADER", act.SplitHorizontal({ domain = "CurrentPaneDomain" }))
|
||||
-- and 'Minus' to split vertically
|
||||
map("-", "LEADER", act.SplitVertical({ domain = "CurrentPaneDomain" }))
|
||||
-- map 1-9 to switch to tab 1-9, 0 for the last tab
|
||||
for i = 1, 9 do
|
||||
map(tostring(i), { "LEADER", "SUPER" }, act.ActivateTab(i - 1))
|
||||
end
|
||||
map("0", { "LEADER", "SUPER" }, act.ActivateTab(-1))
|
||||
-- 'hjkl' to move between panes
|
||||
map("h", { "LEADER", "SUPER" }, act.ActivatePaneDirection("Left"))
|
||||
map("j", { "LEADER", "SUPER" }, act.ActivatePaneDirection("Down"))
|
||||
map("k", { "LEADER", "SUPER" }, act.ActivatePaneDirection("Up"))
|
||||
map("l", { "LEADER", "SUPER" }, act.ActivatePaneDirection("Right"))
|
||||
-- resize
|
||||
map("h", "LEADER|SHIFT", act.AdjustPaneSize({ "Left", 5 }))
|
||||
map("j", "LEADER|SHIFT", act.AdjustPaneSize({ "Down", 5 }))
|
||||
map("k", "LEADER|SHIFT", act.AdjustPaneSize({ "Up", 5 }))
|
||||
map("l", "LEADER|SHIFT", act.AdjustPaneSize({ "Right", 5 }))
|
||||
-- spawn & close
|
||||
map("c", "LEADER", act.SpawnTab("CurrentPaneDomain"))
|
||||
map("x", "LEADER", act.CloseCurrentPane({ confirm = true }))
|
||||
map("t", "SHIFT|CTRL", act.SpawnTab("CurrentPaneDomain"))
|
||||
map("t", "SUPER", act.SpawnTab("CurrentPaneDomain"))
|
||||
map("w", "SHIFT|CTRL", act.CloseCurrentTab({ confirm = true }))
|
||||
map("w", "SUPER", act.CloseCurrentTab({ confirm = true }))
|
||||
-- zoom states
|
||||
map("z", { "LEADER", "SUPER" }, act.TogglePaneZoomState)
|
||||
map("Z", { "LEADER", "SUPER" }, toggleTabBar)
|
||||
-- copy & paste
|
||||
map("v", "LEADER", act.ActivateCopyMode)
|
||||
map("c", { "SHIFT|CTRL", "SUPER" }, act.CopyTo("Clipboard"))
|
||||
map("v", { "SHIFT|CTRL", "SUPER" }, act.PasteFrom("Clipboard"))
|
||||
map("f", { "SHIFT|CTRL", "SUPER" }, act.Search("CurrentSelectionOrEmptyString"))
|
||||
-- rotation
|
||||
map("r", { "LEADER", "SUPER" }, act.RotatePanes("Clockwise"))
|
||||
-- pickers
|
||||
map(" ", "LEADER", act.QuickSelect)
|
||||
map("o", { "LEADER", "SUPER" }, openUrl)
|
||||
map("p", { "LEADER", "SUPER" }, act.PaneSelect({ alphabet = "asdfghjkl;" }))
|
||||
map("R", { "LEADER", "SUPER" }, act.ReloadConfiguration)
|
||||
map("u", "SHIFT|CTRL", act.CharSelect)
|
||||
-- view
|
||||
map("Enter", "ALT", act.ToggleFullScreen)
|
||||
map("-", { "CTRL", "SUPER" }, act.DecreaseFontSize)
|
||||
map("=", { "CTRL", "SUPER" }, act.IncreaseFontSize)
|
||||
map("0", { "CTRL", "SUPER" }, act.ResetFontSize)
|
||||
-- OS defaults
|
||||
map("n", "SHIFT|CTRL", act.SpawnWindow)
|
||||
map("n", "SUPER", act.SpawnWindow)
|
||||
-- debug
|
||||
map("l", "SHIFT|CTRL", act.ShowDebugOverlay)
|
||||
|
||||
{ key = "c", mods = "SHIFT|CTRL", action = act.CopyTo("Clipboard") },
|
||||
{ key = "c", mods = "SUPER", action = act.CopyTo("Clipboard") },
|
||||
{ key = "v", mods = "SHIFT|CTRL", action = act.PasteFrom("Clipboard") },
|
||||
{ key = "v", mods = "SUPER", action = act.PasteFrom("Clipboard") },
|
||||
|
||||
{
|
||||
key = "f",
|
||||
mods = "SHIFT|CTRL",
|
||||
action = act.Search("CurrentSelectionOrEmptyString"),
|
||||
},
|
||||
{
|
||||
key = "f",
|
||||
mods = "SUPER",
|
||||
action = act.Search("CurrentSelectionOrEmptyString"),
|
||||
},
|
||||
|
||||
{ key = "l", mods = "SHIFT|CTRL", action = act.ShowDebugOverlay },
|
||||
|
||||
{
|
||||
key = "p",
|
||||
mods = "LEADER",
|
||||
action = act.PaneSelect({ alphabet = "asdfghjkl;", mode = "Activate" }),
|
||||
},
|
||||
{
|
||||
key = "P",
|
||||
mods = "LEADER",
|
||||
action = act.PaneSelect({
|
||||
alphabet = "asdfghjkl;",
|
||||
mode = "SwapWithActive",
|
||||
}),
|
||||
},
|
||||
|
||||
{
|
||||
key = "p",
|
||||
mods = "SUPER",
|
||||
action = act.PaneSelect({ alphabet = "asdfghjkl;", mode = "Activate" }),
|
||||
},
|
||||
{
|
||||
key = "P",
|
||||
mods = "SUPER",
|
||||
action = act.PaneSelect({
|
||||
alphabet = "asdfghjkl;",
|
||||
mode = "SwapWithActive",
|
||||
}),
|
||||
},
|
||||
{ key = "R", mods = "LEADER", action = act.ReloadConfiguration },
|
||||
|
||||
-- mostly OS defaults
|
||||
{ key = "n", mods = "SHIFT|CTRL", action = act.SpawnWindow },
|
||||
{ key = "n", mods = "SUPER", action = act.SpawnWindow },
|
||||
{
|
||||
key = "t",
|
||||
mods = "SHIFT|CTRL",
|
||||
action = act.SpawnTab("CurrentPaneDomain"),
|
||||
},
|
||||
{ key = "t", mods = "SUPER", action = act.SpawnTab("CurrentPaneDomain") },
|
||||
{
|
||||
key = "w",
|
||||
mods = "SHIFT|CTRL",
|
||||
action = act.CloseCurrentTab({ confirm = true }),
|
||||
},
|
||||
{
|
||||
key = "w",
|
||||
mods = "SUPER",
|
||||
action = act.CloseCurrentTab({ confirm = true }),
|
||||
},
|
||||
{
|
||||
key = "u",
|
||||
mods = "SHIFT|CTRL",
|
||||
action = act.CharSelect({
|
||||
copy_on_select = true,
|
||||
copy_to = "ClipboardAndPrimarySelection",
|
||||
}),
|
||||
},
|
||||
return {
|
||||
leader = { key = "s", mods = "CTRL", timeout_milliseconds = 5000 },
|
||||
keys = shortcuts,
|
||||
disable_default_key_bindings = true,
|
||||
}
|
||||
|
|
|
@ -1,23 +1,16 @@
|
|||
local wezterm = require("wezterm")
|
||||
local fonts = require("fonts")
|
||||
local theme = require("theme")
|
||||
local shortcuts = require("shortcuts")
|
||||
require("bar")
|
||||
|
||||
local font = fonts.get_font("berkeley")
|
||||
local font = require("fonts").get_font("berkeley")
|
||||
wezterm.GLOBAL = {
|
||||
enable_tab_bar = true,
|
||||
}
|
||||
|
||||
return {
|
||||
local options = {
|
||||
set_environment_variables = {
|
||||
TERMINFO_DIRS = wezterm.home_dir .. "/.nix-profile/share/terminfo",
|
||||
},
|
||||
-- keys
|
||||
disable_default_key_bindings = true,
|
||||
leader = { key = "s", mods = "CTRL", timeout_milliseconds = 5000 },
|
||||
term = "wezterm",
|
||||
keys = shortcuts,
|
||||
-- font
|
||||
font = font.font,
|
||||
font_size = font.size,
|
||||
|
@ -54,3 +47,9 @@ return {
|
|||
default_cursor_style = "BlinkingBar",
|
||||
enable_scroll_bar = false,
|
||||
}
|
||||
|
||||
for k, v in pairs(require("shortcuts")) do
|
||||
options[k] = v
|
||||
end
|
||||
|
||||
return options
|
||||
|
|
Loading…
Reference in a new issue