Created
April 21, 2026 14:07
-
-
Save magicstone1412/1cda62e646535ce679e99a6f35a21f0a to your computer and use it in GitHub Desktop.
WezTerm config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- WezTerm Configuration | |
| -- ~/.wezterm.lua hoặc %USERPROFILE%\.wezterm.lua (Windows) | |
| local wezterm = require("wezterm") | |
| local act = wezterm.action | |
| local config = wezterm.config_builder() | |
| -- ============================================================ | |
| -- SSH Domain | |
| -- ============================================================ | |
| config.ssh_domains = { | |
| { | |
| name = "omv175", | |
| remote_address = "10.10.0.10:22", | |
| username = "root", | |
| ssh_option = { | |
| identityfile = "C:\\Users\\skywirex\\.ssh\\id_ed25519-OMV175", | |
| }, | |
| }, | |
| } | |
| -- ============================================================ | |
| -- Command Palette (Ctrl+Shift+P) – SSH shortcut | |
| -- ============================================================ | |
| -- Khi gõ Ctrl+Shift+P rồi tìm "SSH omv175", action dưới đây sẽ hiển thị. | |
| -- WezTerm's built-in CommandPalette tự động liệt kê các mục trong | |
| -- config.command_palette_rows, nên ta đăng ký một entry tuỳ chỉnh. | |
| config.command_palette_rows = 10 | |
| config.command_palette_font_size = 14 | |
| -- Cách đúng để thêm lệnh tuỳ chỉnh vào Command Palette là dùng | |
| -- wezterm.plugin hoặc key_table, nhưng cách đơn giản nhất là bind | |
| -- Ctrl+Shift+P → ActivateCommandPalette và bổ sung entry qua | |
| -- wezterm.action_callback + SwitchToWorkspace/SpawnCommandInNewTab. | |
| -- Ta dùng một KeyTable phụ trợ để người dùng KHÔNG cần gõ thêm gì: | |
| -- chỉ cần bind thêm một phím riêng "mở SSH omv175 ngay trong pane". | |
| -- ============================================================ | |
| -- Key Bindings | |
| -- ============================================================ | |
| config.keys = { | |
| -- ---------------------------------------------------------- | |
| -- TAB | |
| -- ---------------------------------------------------------- | |
| -- Ctrl+Shift+N → mở tab mới (cùng domain hiện tại) | |
| { | |
| key = "N", | |
| mods = "CTRL|SHIFT", | |
| action = act.SpawnTab("CurrentPaneDomain"), | |
| }, | |
| -- Ctrl+Shift+E → đóng tab hiện tại (không hỏi lại) | |
| { | |
| key = "E", | |
| mods = "CTRL|SHIFT", | |
| action = act.CloseCurrentTab({ confirm = false }), | |
| }, | |
| -- Ctrl+Tab → tab kế tiếp | |
| { | |
| key = "Tab", | |
| mods = "CTRL", | |
| action = act.ActivateTabRelative(1), | |
| }, | |
| -- Ctrl+Shift+Tab → tab trước đó | |
| { | |
| key = "Tab", | |
| mods = "CTRL|SHIFT", | |
| action = act.ActivateTabRelative(-1), | |
| }, | |
| -- Ctrl+Shift+1..8 → chuyển tới tab số 1..8 | |
| { key = "1", mods = "CTRL|SHIFT", action = act.ActivateTab(0) }, | |
| { key = "2", mods = "CTRL|SHIFT", action = act.ActivateTab(1) }, | |
| { key = "3", mods = "CTRL|SHIFT", action = act.ActivateTab(2) }, | |
| { key = "4", mods = "CTRL|SHIFT", action = act.ActivateTab(3) }, | |
| { key = "5", mods = "CTRL|SHIFT", action = act.ActivateTab(4) }, | |
| { key = "6", mods = "CTRL|SHIFT", action = act.ActivateTab(5) }, | |
| { key = "7", mods = "CTRL|SHIFT", action = act.ActivateTab(6) }, | |
| { key = "8", mods = "CTRL|SHIFT", action = act.ActivateTab(7) }, | |
| -- Ctrl+Shift+9 → chuyển tab cuối | |
| { | |
| key = "9", | |
| mods = "CTRL|SHIFT", | |
| action = act.ActivateLastTab, | |
| }, | |
| -- Ctrl+Shift+W → mở cửa sổ mới | |
| { | |
| key = "W", | |
| mods = "CTRL|SHIFT", | |
| action = act.SpawnWindow, | |
| }, | |
| -- ---------------------------------------------------------- | |
| -- PANE – chia | |
| -- ---------------------------------------------------------- | |
| -- Ctrl+\ → chia pane ngang (hai cột, split theo chiều ngang) | |
| { | |
| key = "\\", | |
| mods = "CTRL", | |
| action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }), | |
| }, | |
| -- Ctrl+- → chia pane dọc (hai hàng, split theo chiều dọc) | |
| { | |
| key = "-", | |
| mods = "CTRL", | |
| action = act.SplitVertical({ domain = "CurrentPaneDomain" }), | |
| }, | |
| -- ---------------------------------------------------------- | |
| -- PANE – chuyển focus | |
| -- ---------------------------------------------------------- | |
| { key = "LeftArrow", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Left") }, | |
| { key = "RightArrow", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Right") }, | |
| { key = "UpArrow", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Up") }, | |
| { key = "DownArrow", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Down") }, | |
| -- ---------------------------------------------------------- | |
| -- PANE – resize | |
| -- ---------------------------------------------------------- | |
| { key = "LeftArrow", mods = "CTRL|ALT|SHIFT", action = act.AdjustPaneSize({ "Left", 5 }) }, | |
| { key = "RightArrow", mods = "CTRL|ALT|SHIFT", action = act.AdjustPaneSize({ "Right", 5 }) }, | |
| { key = "UpArrow", mods = "CTRL|ALT|SHIFT", action = act.AdjustPaneSize({ "Up", 5 }) }, | |
| { key = "DownArrow", mods = "CTRL|ALT|SHIFT", action = act.AdjustPaneSize({ "Down", 5 }) }, | |
| -- ---------------------------------------------------------- | |
| -- Command Palette (built-in) – Ctrl+Shift+P | |
| -- ---------------------------------------------------------- | |
| { | |
| key = "P", | |
| mods = "CTRL|SHIFT", | |
| action = act.ActivateCommandPalette, | |
| }, | |
| -- ---------------------------------------------------------- | |
| -- SSH omv175 – inject lệnh vào pane hiện tại (Ctrl+Shift+O) | |
| -- ---------------------------------------------------------- | |
| { | |
| key = "O", | |
| mods = "CTRL|SHIFT", | |
| action = act.SendString( | |
| "ssh -i C:\\Users\\skywirex\\.ssh\\id_ed25519-OMV175 -p 22 root@10.10.0.10\r" | |
| ), | |
| }, | |
| } | |
| -- ============================================================ | |
| -- Command Palette custom entries | |
| -- Đăng ký entry "SSH omv175" xuất hiện khi tìm kiếm trong palette. | |
| -- ============================================================ | |
| -- wezterm.on cho phép hook vào augment-command-palette để thêm lệnh tuỳ chỉnh. | |
| wezterm.on("augment-command-palette", function(window, pane) | |
| return { | |
| { | |
| brief = "SSH omv175", | |
| icon = "md_server_network", | |
| -- Inject lệnh ssh vào pane đang focus, KHÔNG mở tab mới | |
| action = act.SendString( | |
| "ssh -i C:\\Users\\skywirex\\.ssh\\id_ed25519-OMV175 -p 22 root@10.10.0.10\r" | |
| ), | |
| }, | |
| } | |
| end) | |
| -- ============================================================ | |
| -- Tuỳ chỉnh giao diện (tuỳ chọn, bỏ comment nếu muốn) | |
| -- ============================================================ | |
| -- config.color_scheme = "Tokyo Night" | |
| -- config.font = wezterm.font("JetBrains Mono", { weight = "Regular" }) | |
| -- config.font_size = 13.0 | |
| -- config.window_background_opacity = 0.95 | |
| -- config.hide_tab_bar_if_only_one_tab = false | |
| return config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment