diff --git a/tools/wezterm/appearance.lua b/tools/wezterm/appearance.lua new file mode 100644 index 0000000..ab90d01 --- /dev/null +++ b/tools/wezterm/appearance.lua @@ -0,0 +1,47 @@ +local wezterm = require("wezterm") +local os_type = require("utils").detected_os +local color = require("color") + +return function(config) + config.max_fps = 120 + config.font = wezterm.font({ + family = "JetBrainsMono Nerd Font", + }) + config.color_scheme = "Catppuccin Mocha" + config.font_size = 12.0 + config.front_end = "WebGpu" + config.webgpu_power_preference = "HighPerformance" + if os_type.is_win then + config.window_background_opacity = 0.7 -- Not working under WebGpu + config.win32_system_backdrop = "Mica" + end + config.window_padding = { + left = 0, + right = 0, + top = 0, + bottom = 0, + } + -- Cursor + config.animation_fps = 120 + config.cursor_blink_ease_in = "EaseOut" + config.cursor_blink_ease_out = "EaseOut" + config.default_cursor_style = "BlinkingBlock" + config.cursor_blink_rate = 650 + -- Visual Bell + config.visual_bell = { + fade_in_function = "EaseIn", + fade_in_duration_ms = 250, + fade_out_function = "EaseOut", + fade_out_duration_ms = 250, + target = "CursorColor", + } + -- Command Palette + config.window_frame = { + font = wezterm.font("PingFang SC"), + } + + config.command_palette_fg_color = color.lavender + config.command_palette_bg_color = color.base + -- UnixLong / Emacs / AppleSymbols / WindowsLong / WindowsSymbols + config.ui_key_cap_rendering = "AppleSymbols" +end diff --git a/tools/wezterm/color.lua b/tools/wezterm/color.lua new file mode 100644 index 0000000..39fe905 --- /dev/null +++ b/tools/wezterm/color.lua @@ -0,0 +1,30 @@ +local mocha = { + rosewater = "#f5e0dc", + flamingo = "#f2cdcd", + pink = "#f5c2e7", + mauve = "#cba6f7", + red = "#f38ba8", + maroon = "#eba0ac", + peach = "#fab387", + yellow = "#f9e2af", + green = "#a6e3a1", + teal = "#94e2d5", + sky = "#89dceb", + sapphire = "#74c7ec", + blue = "#89b4fa", + lavender = "#b4befe", + text = "#cdd6f4", + subtext1 = "#bac2de", + subtext0 = "#a6adc8", + overlay2 = "#9399b2", + overlay1 = "#7f849c", + overlay0 = "#6c7086", + surface2 = "#585b70", + surface1 = "#45475a", + surface0 = "#313244", + base = "#1e1e2e", + mantle = "#181825", + crust = "#11111b", +} + +return mocha diff --git a/tools/wezterm/keymaps.lua b/tools/wezterm/keymaps.lua new file mode 100644 index 0000000..25de9ea --- /dev/null +++ b/tools/wezterm/keymaps.lua @@ -0,0 +1,268 @@ +-- vim: foldmethod=marker foldmarker=#region,#endregion +-- Reference to: https://github.com/KevinSilvester/wezterm-config/blob/master/config/bindings.lua +local wezterm = require("wezterm") +local action = wezterm.action +local act = wezterm.action +local os_type = require("utils").detected_os + +local SUPER + +if os_type.is_mac then + SUPER = "SUPER" +else + SUPER = "ALT" +end + +-- #region Key Tables +local key_tables = { + copy_mode = { + -- #region Built-in CopyMode + -- This keymaps seems cannot be merged. + { key = "Tab", mods = "NONE", action = act.CopyMode("MoveForwardWord") }, + { key = "Tab", mods = "SHIFT", action = act.CopyMode("MoveBackwardWord") }, + { key = "Enter", mods = "NONE", action = act.CopyMode("MoveToStartOfNextLine") }, + { key = "Escape", mods = "NONE", action = act.Multiple({ "ScrollToBottom", { CopyMode = "Close" } }) }, + { key = "Space", mods = "NONE", action = act.CopyMode({ SetSelectionMode = "Cell" }) }, + { key = "$", mods = "NONE", action = act.CopyMode("MoveToEndOfLineContent") }, + { key = "$", mods = "SHIFT", action = act.CopyMode("MoveToEndOfLineContent") }, + { key = ",", mods = "NONE", action = act.CopyMode("JumpReverse") }, + { key = "0", mods = "NONE", action = act.CopyMode("MoveToStartOfLine") }, + { key = ";", mods = "NONE", action = act.CopyMode("JumpAgain") }, + { key = "F", mods = "NONE", action = act.CopyMode({ JumpBackward = { prev_char = false } }) }, + { key = "F", mods = "SHIFT", action = act.CopyMode({ JumpBackward = { prev_char = false } }) }, + { key = "G", mods = "NONE", action = act.CopyMode("MoveToScrollbackBottom") }, + { key = "G", mods = "SHIFT", action = act.CopyMode("MoveToScrollbackBottom") }, + { key = "H", mods = "NONE", action = act.CopyMode("MoveToViewportTop") }, + { key = "H", mods = "SHIFT", action = act.CopyMode("MoveToViewportTop") }, + { key = "L", mods = "NONE", action = act.CopyMode("MoveToViewportBottom") }, + { key = "L", mods = "SHIFT", action = act.CopyMode("MoveToViewportBottom") }, + { key = "M", mods = "NONE", action = act.CopyMode("MoveToViewportMiddle") }, + { key = "M", mods = "SHIFT", action = act.CopyMode("MoveToViewportMiddle") }, + { key = "O", mods = "NONE", action = act.CopyMode("MoveToSelectionOtherEndHoriz") }, + { key = "O", mods = "SHIFT", action = act.CopyMode("MoveToSelectionOtherEndHoriz") }, + { key = "T", mods = "NONE", action = act.CopyMode({ JumpBackward = { prev_char = true } }) }, + { key = "T", mods = "SHIFT", action = act.CopyMode({ JumpBackward = { prev_char = true } }) }, + { key = "V", mods = "NONE", action = act.CopyMode({ SetSelectionMode = "Line" }) }, + { key = "V", mods = "SHIFT", action = act.CopyMode({ SetSelectionMode = "Line" }) }, + { key = "^", mods = "NONE", action = act.CopyMode("MoveToStartOfLineContent") }, + { key = "^", mods = "SHIFT", action = act.CopyMode("MoveToStartOfLineContent") }, + { key = "b", mods = "NONE", action = act.CopyMode("MoveBackwardWord") }, + { key = "b", mods = "ALT", action = act.CopyMode("MoveBackwardWord") }, + { key = "b", mods = "CTRL", action = act.CopyMode("PageUp") }, + { key = "c", mods = "CTRL", action = act.Multiple({ "ScrollToBottom", { CopyMode = "Close" } }) }, + { key = "d", mods = "CTRL", action = act.CopyMode({ MoveByPage = 0.5 }) }, + { key = "e", mods = "NONE", action = act.CopyMode("MoveForwardWordEnd") }, + { key = "f", mods = "NONE", action = act.CopyMode({ JumpForward = { prev_char = false } }) }, + { key = "f", mods = "ALT", action = act.CopyMode("MoveForwardWord") }, + { key = "f", mods = "CTRL", action = act.CopyMode("PageDown") }, + { key = "g", mods = "NONE", action = act.CopyMode("MoveToScrollbackTop") }, + { key = "g", mods = "CTRL", action = act.Multiple({ "ScrollToBottom", { CopyMode = "Close" } }) }, + { key = "h", mods = "NONE", action = act.CopyMode("MoveLeft") }, + { key = "j", mods = "NONE", action = act.CopyMode("MoveDown") }, + { key = "k", mods = "NONE", action = act.CopyMode("MoveUp") }, + { key = "l", mods = "NONE", action = act.CopyMode("MoveRight") }, + { key = "m", mods = "ALT", action = act.CopyMode("MoveToStartOfLineContent") }, + { key = "o", mods = "NONE", action = act.CopyMode("MoveToSelectionOtherEnd") }, + { key = "q", mods = "NONE", action = act.Multiple({ "ScrollToBottom", { CopyMode = "Close" } }) }, + { key = "t", mods = "NONE", action = act.CopyMode({ JumpForward = { prev_char = true } }) }, + { key = "u", mods = "CTRL", action = act.CopyMode({ MoveByPage = -0.5 }) }, + { key = "v", mods = "NONE", action = act.CopyMode({ SetSelectionMode = "Cell" }) }, + { key = "v", mods = "CTRL", action = act.CopyMode({ SetSelectionMode = "Block" }) }, + { key = "w", mods = "NONE", action = act.CopyMode("MoveForwardWord") }, + { + key = "y", + mods = "NONE", + action = act.Multiple({ + { CopyTo = "ClipboardAndPrimarySelection" }, + { Multiple = { "ScrollToBottom", { CopyMode = "Close" } } }, + }), + }, + { key = "PageUp", mods = "NONE", action = act.CopyMode("PageUp") }, + { key = "PageDown", mods = "NONE", action = act.CopyMode("PageDown") }, + { key = "End", mods = "NONE", action = act.CopyMode("MoveToEndOfLineContent") }, + { key = "Home", mods = "NONE", action = act.CopyMode("MoveToStartOfLine") }, + { key = "LeftArrow", mods = "NONE", action = act.CopyMode("MoveLeft") }, + { key = "LeftArrow", mods = "ALT", action = act.CopyMode("MoveBackwardWord") }, + { key = "RightArrow", mods = "NONE", action = act.CopyMode("MoveRight") }, + { key = "RightArrow", mods = "ALT", action = act.CopyMode("MoveForwardWord") }, + { key = "UpArrow", mods = "NONE", action = act.CopyMode("MoveUp") }, + { key = "DownArrow", mods = "NONE", action = act.CopyMode("MoveDown") }, + -- #endregion + -- #region Customized CopyMode + { key = "n", mods = "NONE", action = act.CopyMode("MoveDown") }, + { key = "e", mods = "NONE", action = act.CopyMode("MoveUp") }, + { key = "i", mods = "NONE", action = act.CopyMode("MoveRight") }, + { key = "j", mods = "NONE", action = act.CopyMode("MoveForwardWordEnd") }, + -- #endregion + }, + resize_pane = { + { key = "h", mods = "NONE", action = act.AdjustPaneSize({ "Left", 1 }) }, + { key = "n", mods = "NONE", action = act.AdjustPaneSize({ "Down", 1 }) }, + { key = "e", mods = "NONE", action = act.AdjustPaneSize({ "Up", 1 }) }, + { key = "i", mods = "NONE", action = act.AdjustPaneSize({ "Right", 1 }) }, + { key = "q", mods = "NONE", action = "PopKeyTable" }, + }, +} +-- #endregion + +-- #region Leader Keymaps +local leader_keys = { + { + key = "q", + mods = "LEADER", + action = act.SendKey({ key = "q", mods = "CTRL" }), + }, + -- Windows Management + { -- leader keys + key = "|", + mods = "LEADER|SHIFT", + action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }), + }, + { + key = "-", + mods = "LEADER", + action = act.SplitVertical({ domain = "CurrentPaneDomain" }), + }, + { + key = "h", + mods = "LEADER", + action = act.ActivatePaneDirection("Left"), + }, + { + key = "n", + mods = "LEADER", + action = act.ActivatePaneDirection("Down"), + }, + { + key = "e", + mods = "LEADER", + action = act.ActivatePaneDirection("Up"), + }, + { + key = "i", + mods = "LEADER", + action = act.ActivatePaneDirection("Right"), + }, + { + key = "H", + mods = "LEADER", + action = act.AdjustPaneSize({ "Left", 5 }), + }, + { + key = "N", + mods = "LEADER", + action = act.AdjustPaneSize({ "Down", 5 }), + }, + { + key = "E", + mods = "LEADER", + action = act.AdjustPaneSize({ "Up", 5 }), + }, + { + key = "I", + mods = "LEADER", + action = act.AdjustPaneSize({ "Right", 5 }), + }, + { + key = "/", + mods = "LEADER", + action = act.Search({ Regex = "" }), + }, + { + key = "?", + mods = "LEADER|SHIFT", + action = act.Search({ CaseSensitiveString = "" }), + }, + { + key = ";", + mods = "LEADER", + action = act.ShowLauncher, + }, + { + key = ":", + mods = "LEADER|SHIFT", + action = act.ActivateCommandPalette, + }, + { + key = "r", + mods = "LEADER", + action = act.ActivateKeyTable({ + name = "resize_pane", + one_shot = false, + timeout_milliseconds = 2000, + }), + }, +} +-- #endregion + +-- #region Ctrl Keymaps +local ctrl_keys = { + { + key = "W", + mods = "CTRL", + action = act.CloseCurrentPane({ confirm = true }), + }, + { -- ^C to copy if selection is active, otherwise send signal + -- https://wezfurlong.org/wezterm/config/lua/keyassignment/ClearSelection.html?h=selection + key = "c", + mods = "CTRL", + action = wezterm.action_callback(function(window, pane) + local has_selection = window:get_selection_text_for_pane(pane) ~= "" + if has_selection then + window:perform_action(act.CopyTo("ClipboardAndPrimarySelection"), pane) + + window:perform_action(act.ClearSelection, pane) + else + window:perform_action(act.SendKey({ key = "c", mods = "CTRL" }), pane) + end + end), + }, +} +-- #endregion + +-- #region SUPER Keymaps +local super_keys = { + { key = "LeftArrow", mods = SUPER, action = act.SendString("\u{1b}OH") }, + { key = "RightArrow", mods = SUPER, action = act.SendString("\u{1b}OF") }, + { key = "Backspace", mods = SUPER, action = act.SendString("\u{15}") }, + { key = "0", mods = SUPER, action = act.ActivateTab(-1) }, + { key = "t", mods = SUPER, action = act.SpawnTab("DefaultDomain") }, + { key = "w", mods = SUPER, action = act.CloseCurrentTab({ confirm = false }) }, +} +for i = 1, 9 do + table.insert(super_keys, { key = tostring(i), mods = SUPER, action = act.ActivateTab(i - 1) }) +end +-- #endregion + +-- Concat all keymaps +local keys = {} + +for _, keymap in ipairs(leader_keys) do + table.insert(keys, keymap) +end + +for _, keymap in ipairs(ctrl_keys) do + table.insert(keys, keymap) +end + +for _, keymap in ipairs(super_keys) do + table.insert(keys, keymap) +end + +return function(config) + config.leader = { key = "q", mods = "CTRL" } + config.keys = keys + config.key_tables = key_tables + config.mouse_bindings = { + { + event = { Up = { streak = 1, button = "Left" } }, + mods = "CTRL", + action = act.OpenLinkAtMouseCursor, + }, + { + event = { Up = { streak = 1, button = "Left" } }, + mods = "SUPER", + action = act.OpenLinkAtMouseCursor, + }, + } +end diff --git a/tools/wezterm/launcher.lua b/tools/wezterm/launcher.lua new file mode 100644 index 0000000..90fdc18 --- /dev/null +++ b/tools/wezterm/launcher.lua @@ -0,0 +1,63 @@ +local os_type = require("utils").detected_os + +return function(config) + if os_type.is_win then + config.default_prog = { "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" } + config.launch_menu = { + { + label = "Local - PowerShell", + args = { "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" }, + }, + { + label = "Local - PowerShell Administator", + args = { "sudo.exe", "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" }, + }, + { + label = "WSL1 - Arch", + args = { "wsl.exe", "-d", "Arch" }, + }, + { + label = "WSL2 - kali-linux", + args = { "wsl.exe", "-d", "kali-linux" }, + }, + { + label = "Local - NuShell", + args = { "nu" }, + }, + { + label = "Local - Windows PowerShell", + args = { "powershell.exe" }, + }, + { + label = "Local - Command Prompt", + args = { "cmd.exe" }, + }, + { + label = "WSL1 - Arch Zsh", + args = { "wsl.exe", "-d", "Arch", "zsh" }, + }, + } + elseif os_type.is_mac then + config.default_prog = { "/opt/homebrew/bin/fish", "-l" } + else + config.default_prog = { "fish" } + config.launch_menu = { + { + label = "Local - Fish", + args = { "fish", "-l" }, + }, + { + label = "Local - Zsh", + args = { "zsh", "-l" }, + }, + { + label = "Local - PowerShell", + args = { "pwsh", "-NoLogo", "-NoProfileLoadTime", "-Login" }, + }, + { + label = "Local - NuShell", + args = { "nu", "-l" }, + }, + } + end +end diff --git a/tools/wezterm/misc.lua b/tools/wezterm/misc.lua new file mode 100644 index 0000000..a70a2d2 --- /dev/null +++ b/tools/wezterm/misc.lua @@ -0,0 +1,7 @@ +return function(config) + -- Environment + config.set_environment_variables = { + TERM = "xterm-256color", + TERM_PROGRAM = "wezterm", + } +end diff --git a/tools/wezterm/tab.lua b/tools/wezterm/tab.lua new file mode 100644 index 0000000..b26ac33 --- /dev/null +++ b/tools/wezterm/tab.lua @@ -0,0 +1,125 @@ +local wezterm = require("wezterm") +local nf = wezterm.nerdfonts +local color = require("color") + +local tabline = wezterm.plugin.require("https://github.com/michaelbrusegard/tabline.wez") +tabline.setup({ + options = { + icons_enabled = true, + theme = "Catppuccin Mocha", + tabs_enabled = true, + theme_overrides = { + tab = { + inactive = { bg = color.base, fg = color.text }, + active = { fg = color.lavender, bg = color.surface0 }, + inactive_hover = { fg = color.pink, bg = color.surface0 }, + }, + normal_mode = { + a = { fg = color.mantle, bg = color.lavender }, -- bg: Lavender (Mocha) + b = { fg = color.lavender, bg = color.surface0 }, -- fg: Lavender (Mocha) + c = { bg = color.base, fg = color.text }, + }, + copy_mode = { + c = { bg = color.base, fg = color.text }, + }, + search_mode = { + c = { bg = color.base, fg = color.text }, + }, + window_mode = { + c = { bg = color.base, fg = color.text }, + }, + }, + section_separators = { + left = nf.ple_flame_thick, + right = nf.ple_flame_thick_mirrored, + }, + component_separators = { + left = nf.ple_flame_thick, + right = nf.ple_flame_thick_mirrored, + }, + tab_separators = { + left = nf.ple_ice_waveform, + right = nf.ple_ice_waveform_mirrored, + }, + }, + sections = { + tabline_a = { + { + "mode", + icon = nf.md_alpha_w_box_outline, + -- icons_only = true, + fmt = function(str) + return str:sub(1, 1) + end, + }, + }, + tabline_b = { "window" }, + tabline_c = { "" }, + tab_active = { + "index", + { "parent", padding = 0 }, + "/", + { "cwd", padding = { left = 0, right = 1 } }, + { "zoomed", padding = 0 }, + }, + tab_inactive = { + "index", + { + "process", + padding = { left = 0, right = 1 }, + process_to_icon = { + ["dotnet"] = { nf.dev_dotnet }, + ["dotnet.exe"] = { nf.dev_dotnet }, + ["emacs"] = { nf.custom_emacs }, + ["pwsh"] = { nf.md_powershell }, + ["pwsh.exe"] = { nf.md_powershell }, + ["powershell.exe"] = { nf.md_powershell }, + ["python3.13"] = { nf.md_language_python }, + ["less"] = { nf.fa_pager }, + ["nu"] = { nf.seti_shell }, + ["nu.exe"] = { nf.seti_shell }, + }, + }, + }, + tabline_x = {}, + tabline_y = { "ram" }, + tabline_z = { "datetime" }, + }, + extensions = {}, +}) + +return function(config) + config.hide_tab_bar_if_only_one_tab = true + config.tab_bar_at_bottom = true + -- If set to false, the tab bar will be terminal-like + config.use_fancy_tab_bar = false + config.colors = { + tab_bar = { + background = color.base, + active_tab = { + -- bg_color = color.pink, + bg_color = color.lavender, + fg_color = color.overlay0, + italic = true, + }, + inactive_tab = { + bg_color = color.base, + fg_color = color.text, + }, + inactive_tab_hover = { + bg_color = color.mauve, + fg_color = color.surface2, + italic = true, + }, + new_tab = { + bg_color = color.base, + fg_color = color.text, + }, + new_tab_hover = { + bg_color = color.surface0, + fg_color = color.pink, + italic = true, + }, + }, + } +end diff --git a/tools/wezterm/utils.lua b/tools/wezterm/utils.lua new file mode 100644 index 0000000..e08d45c --- /dev/null +++ b/tools/wezterm/utils.lua @@ -0,0 +1,37 @@ +local wezterm = require("wezterm") + +local function is_found(str, pattern) + return string.find(str, pattern) ~= nil +end + +local M = {} + +local function platform() + local is_win = is_found(wezterm.target_triple, "windows") + local is_linux = is_found(wezterm.target_triple, "linux") + local is_mac = is_found(wezterm.target_triple, "apple") + local os + + if is_win then + os = "windows" + elseif is_linux then + os = "linux" + elseif is_mac then + os = "mac" + else + error("Unknown platform") + end + + return { + os = os, + is_win = is_win, + is_linux = is_linux, + is_mac = is_mac, + } +end + +local _platform = platform() + +M.detected_os = _platform + +return M diff --git a/tools/wezterm/wezterm.lua b/tools/wezterm/wezterm.lua index 9926c99..545eb3e 100644 --- a/tools/wezterm/wezterm.lua +++ b/tools/wezterm/wezterm.lua @@ -1,280 +1,22 @@ +-- vim: foldmethod=marker foldmarker=#region,#endregion -- $DOTFILES/tools/wezterm/wezterm.lua -- Date: 2024-12-22 -- Author: js0ny ---#region Import & Setup local wezterm = require("wezterm") -local action = wezterm.action +local color = require("color") -local config = {} ---#endregion +local config = wezterm.config_builder() ---#region Helper ---[[ -local function detect_os() - local detected_os = "" - if package.config:sub(1, 1) == "\\" then - -- Windows - detected_os = "Windows" - elseif package.config:sub(1, 1) == "/" then - -- Unix-like (Linux, macOS, etc.) - if os.getenv("HOME") then - detected_os = "Unix-like" - -- You can differentiate further by checking for macOS or Linux if needed - if os.getenv("XDG_SESSION_TYPE") then - -- Likely Linux - detected_os = "Linux" - elseif os.execute("uname -s | grep -i darwin") == 0 then - -- macOS - detected_os = "macOS" - end - end - end - return detected_os -end ---]] ---[[ -wezterm.on("text-selection-callback", function(window, pane) - local text = window:get_selection_text_for_pane(pane) -end) ---]] +-- TODO: OS light/dark theme detection +-- local function detect_theme() end -local function detect_os() - local os_type = "" - if wezterm.target_triple == "x86_64-pc-windows-msvc" then - os_type = "Windows" - elseif wezterm.target_triple == "x86_64-unknown-linux-gnu" then - os_type = "Linux" - elseif wezterm.target_triple == "aarch64-apple-darwin" then - os_type = "macOS" - end - return os_type -end - --- OS light/dark theme detection -local function detect_theme() end ---#endregion - ---#region Constant -local os_type = detect_os() ---#endregion - ---#region Appearance --- Font and color scheme -- config.font = 'FiraCode Nerd Font' -config.max_fps = 120 -config.font = wezterm.font({ - family = "JetBrainsMono Nerd Font", -}) -config.color_scheme = "Catppuccin Mocha" -config.font_size = 12.0 -config.front_end = "WebGpu" -config.webgpu_power_preference = "HighPerformance" -if os_type == "Windows" then - config.window_background_opacity = 0.7 -- Not working under WebGpu - config.win32_system_backdrop = "Mica" -end --- Tab appearance -config.hide_tab_bar_if_only_one_tab = true -config.tab_bar_at_bottom = true --- Cursor --- config.animation_fps = 120 --- config.cursor_blink_ease_in = 'EaseOut' --- config.cursor_blink_ease_out = 'EaseOut' --- config.default_cursor_style = 'BlinkingBlock' --- config.cursor_blink_rate = 650 --- Visual Bell -config.visual_bell = { - fade_in_function = "EaseIn", - fade_in_duration_ms = 250, - fade_out_function = "EaseOut", - fade_out_duration_ms = 250, - target = "CursorColor", -} ---#endregion - ---#region Keybindings -config.leader = { key = "q", mods = "CTRL" } -config.keys = { - { - key = "q", - mods = "LEADER", - action = action.SendKey({ key = "q", mods = "CTRL" }), - }, - -- Windows Management - { -- leader keys - key = "|", - mods = "LEADER|SHIFT", - action = action.SplitHorizontal({ domain = "CurrentPaneDomain" }), - }, - { - key = "-", - mods = "LEADER", - action = action.SplitVertical({ domain = "CurrentPaneDomain" }), - }, - { - key = "h", - mods = "LEADER", - action = action.ActivatePaneDirection("Left"), - }, - { - key = "n", - mods = "LEADER", - action = action.ActivatePaneDirection("Down"), - }, - { - key = "e", - mods = "LEADER", - action = action.ActivatePaneDirection("Up"), - }, - { - key = "i", - mods = "LEADER", - action = action.ActivatePaneDirection("Right"), - }, - { - key = "H", - mods = "LEADER", - action = action.AdjustPaneSize({ "Left", 5 }), - }, - { - key = "N", - mods = "LEADER", - action = action.AdjustPaneSize({ "Down", 5 }), - }, - { - key = "E", - mods = "LEADER", - action = action.AdjustPaneSize({ "Up", 5 }), - }, - { - key = "I", - mods = "LEADER", - action = action.AdjustPaneSize({ "Right", 5 }), - }, - { - key = "/", - mods = "LEADER", - action = action.Search({ Regex = "" }), - }, - { - key = "?", - mods = "LEADER|SHIFT", - action = action.Search({ CaseSensitiveString = "" }), - }, - { - key = ";", - mods = "LEADER", - action = action.ShowLauncher, - }, - { - key = ":", - mods = "LEADER|SHIFT", - action = action.ActivateCommandPalette, - }, - { - key = "W", - mods = "CTRL", - action = action.CloseCurrentPane({ confirm = true }), - }, - { -- ^C to copy if selection is active, otherwise send signal - -- https://wezfurlong.org/wezterm/config/lua/keyassignment/ClearSelection.html?h=selection - key = "c", - mods = "CTRL", - action = wezterm.action_callback(function(window, pane) - local has_selection = window:get_selection_text_for_pane(pane) ~= "" - if has_selection then - window:perform_action(action.CopyTo("ClipboardAndPrimarySelection"), pane) - - window:perform_action(action.ClearSelection, pane) - else - window:perform_action(action.SendKey({ key = "c", mods = "CTRL" }), pane) - end - end), - }, -} -config.mouse_bindings = { - { - event = { Up = { streak = 1, button = "Left" } }, - mods = "CTRL", - action = action.OpenLinkAtMouseCursor, - }, - { - event = { Up = { streak = 1, button = "Left" } }, - mods = "SUPER", - action = action.OpenLinkAtMouseCursor, - }, -} ---#endregion - ---#region Environment -config.set_environment_variables = { - TERM = "xterm-256color", - TERM_PROGRAM = "wezterm" -} ---#endregion - ---#region Launching -if os_type == "Windows" then - config.default_prog = { "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" } - config.launch_menu = { - { - label = "Local - PowerShell", - args = { "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" }, - }, - { - label = "Local - PowerShell Administator", - args = { "sudo.exe", "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" }, - }, - { - label = "WSL1 - Arch", - args = { "wsl.exe", "-d", "Arch" }, - }, - { - label = "WSL2 - kali-linux", - args = { "wsl.exe", "-d", "kali-linux" }, - }, - { - label = "Local - NuShell", - args = { "nu" }, - }, - { - label = "Local - Windows PowerShell", - args = { "powershell.exe" }, - }, - { - label = "Local - Command Prompt", - args = { "cmd.exe" }, - }, - { - label = "WSL1 - Arch Zsh", - args = { "wsl.exe", "-d", "Arch", "zsh" }, - }, - } -elseif os_type == "macOS" then - config.default_prog = { "/opt/homebrew/bin/fish", "-l" } -else - config.default_prog = { "fish" } - config.launch_menu = { - { - label = "Local - Fish", - args = { "fish", "-l" }, - }, - { - label = "Local - Zsh", - args = { "zsh", "-l" }, - }, - { - label = "Local - PowerShell", - args = { "pwsh", "-NoLogo", "-NoProfileLoadTime", "-Login" }, - }, - { - label = "Local - NuShell", - args = { "nu", "-l" }, - }, - } -end ---#endregion +require("tab")(config) +require("appearance")(config) +require("keymaps")(config) +require("launcher")(config) +require("misc")(config) return config