refactor(wezterm): make `binds.lua` & remove WSL config

main
sgoudham 1 year ago
parent d9fbd1f9d9
commit 5d78b2af7e
Signed by: hammy
GPG Key ID: 44E818FD5457EEA4

@ -0,0 +1,64 @@
local wezterm = require("wezterm")
local act = wezterm.action
return {
keyboard = {
-- Fullscreen
{ key = "F11", action = act.ToggleFullScreen },
-- Zoom
{ key = "z", mods = "ALT|SHIFT", action = act.TogglePaneZoomState },
-- Copy / Paste
{ key = "c", mods = "ALT|SHIFT", action = act.CopyTo("Clipboard") },
{ key = "v", mods = "ALT|SHIFT", action = act.PasteFrom("Clipboard") },
-- CMD Palette
{ key = "p", mods = "ALT|SHIFT", action = act.ActivateCommandPalette },
-- Navigating Tabs
{ key = "h", mods = "ALT|SHIFT", action = act.ActivateTabRelative(-1) },
{ key = "l", mods = "ALT|SHIFT", action = act.ActivateTabRelative(1) },
-- Close Tabs
{ key = "d", mods = "ALT|SHIFT", action = act.CloseCurrentTab({ confirm = false }) },
-- Swap Panes
{ key = "i", mods = "ALT|SHIFT", action = act.PaneSelect({ alphabet = "asdfghjkl;", mode = "Activate" }) },
{
key = "s",
mods = "ALT|SHIFT",
action = act.PaneSelect({ alphabet = "asdfghjkl;", mode = "SwapWithActive" }),
},
-- Move Tabs Relatively
{ key = "{", mods = "ALT|SHIFT", action = act.MoveTabRelative(-1) },
{ key = "}", mods = "ALT|SHIFT", action = act.MoveTabRelative(1) },
-- New Tab
{ key = "n", mods = "ALT|SHIFT", action = act({ SpawnTab = "CurrentPaneDomain" }) },
{ key = "m", mods = "ALT|SHIFT", action = act({ SpawnTab = "DefaultDomain" }) },
-- Open Links Via Keyboard
{
key = "o",
mods = "ALT|SHIFT",
action = act.QuickSelectArgs({
label = "open url",
patterns = {
"https?://\\S+",
},
action = wezterm.action_callback(function(window, pane)
local url = window:get_selection_text_for_pane(pane)
wezterm.open_with(url)
end),
}),
},
-- ScrollBack To Prompt
{ key = "UpArrow", mods = "CTRL|SHIFT", action = act.ScrollToPrompt(-1) },
{ key = "DownArrow", mods = "CTRL|SHIFT", action = act.ScrollToPrompt(1) },
},
mouse = {
{
event = { Up = { streak = 1, button = "Left" } },
mods = "CTRL",
action = act.OpenLinkAtMouseCursor,
},
}
}

@ -1,29 +1,7 @@
local wezterm = require("wezterm") local wezterm = require("wezterm")
local act = wezterm.action local act = wezterm.action
local wsl_domains = wezterm.default_wsl_domains()
local c = wezterm.config_builder() local c = wezterm.config_builder()
-- WSL related
for _, dom in ipairs(wsl_domains) do
dom.default_cwd = "~"
end
local function get_os()
local target = wezterm.target_triple
if string.find(target, "linux") then
return "linux"
elseif string.find(target, "darwin") then
return "macos"
else
return "windows"
end
end
if get_os() == "windows" then
default_prog = { "wsl.exe", "~", "-d", "Ubuntu-20.04" }
default_domain = "WSL:Ubuntu-20.04"
end
c.set_environment_variables = { c.set_environment_variables = {
ZVM_TERM = "xterm-256color", ZVM_TERM = "xterm-256color",
} }
@ -40,8 +18,6 @@ c.font = wezterm.font_with_fallback({
}) })
c.font_size = 12 c.font_size = 12
c.default_domain = default_domain
c.wsl_domains = wsl_domains
c.default_prog = { "fish", "-l" } c.default_prog = { "fish", "-l" }
c.window_padding = { top = 1, bottom = 1, left = 1, right = 1 } c.window_padding = { top = 1, bottom = 1, left = 1, right = 1 }
@ -60,65 +36,9 @@ c.clean_exit_codes = { 130 }
c.audible_bell = "Disabled" c.audible_bell = "Disabled"
c.disable_default_key_bindings = false c.disable_default_key_bindings = false
c.mouse_bindings = { local binds = require("binds")
{ c.keys = binds.keyboard
event = { Up = { streak = 1, button = "Left" } }, c.mouse_bindings = binds.mouse
mods = "CTRL",
action = wezterm.action.OpenLinkAtMouseCursor,
},
}
c.keys = {
-- Fullscreen
{ key = "F11", action = wezterm.action.ToggleFullScreen },
-- Zoom
{ key = "z", mods = "ALT|SHIFT", action = wezterm.action.TogglePaneZoomState },
-- Copy / Paste
{ key = "c", mods = "ALT|SHIFT", action = wezterm.action.CopyTo("Clipboard") },
{ key = "v", mods = "ALT|SHIFT", action = act.PasteFrom("Clipboard") },
-- CMD Palette
{ key = "p", mods = "ALT|SHIFT", action = act.ActivateCommandPalette },
-- Navigating Tabs
{ key = "h", mods = "ALT|SHIFT", action = act.ActivateTabRelative(-1) },
{ key = "l", mods = "ALT|SHIFT", action = act.ActivateTabRelative(1) },
-- Close Tabs
{ key = "d", mods = "ALT|SHIFT", action = act.CloseCurrentTab({ confirm = false }) },
-- Swap Panes
{ key = "i", mods = "ALT|SHIFT", action = act.PaneSelect({ alphabet = "asdfghjkl;", mode = "Activate" }) },
{
key = "s",
mods = "ALT|SHIFT",
action = act.PaneSelect({ alphabet = "asdfghjkl;", mode = "SwapWithActive" }),
},
-- Move Tabs Relatively
{ key = "{", mods = "ALT|SHIFT", action = act.MoveTabRelative(-1) },
{ key = "}", mods = "ALT|SHIFT", action = act.MoveTabRelative(1) },
-- New Tab
{ key = "n", mods = "ALT|SHIFT", action = act({ SpawnTab = "CurrentPaneDomain" }) },
{ key = "m", mods = "ALT|SHIFT", action = act({ SpawnTab = "DefaultDomain" }) },
-- Open Links Via Keyboard
{
key = "o",
mods = "ALT|SHIFT",
action = wezterm.action.QuickSelectArgs({
label = "open url",
patterns = {
"https?://\\S+",
},
action = wezterm.action_callback(function(window, pane)
local url = window:get_selection_text_for_pane(pane)
wezterm.open_with(url)
end),
}),
},
-- ScrollBack To Prompt
{ key = "UpArrow", mods = "CTRL|SHIFT", action = act.ScrollToPrompt(-1) },
{ key = "DownArrow", mods = "CTRL|SHIFT", action = act.ScrollToPrompt(1) },
}
c.ssh_domains = { c.ssh_domains = {
{ {

Loading…
Cancel
Save