├── .editorconfig
├── .gitignore
├── .luarc.json
├── .stylua.toml
├── LICENSE
├── README.md
├── backdrops
└── space.jpg
├── colors
└── custom.lua
├── config
├── appearance.lua
├── bindings.lua
├── domains.lua
├── fonts.lua
├── general.lua
├── init.lua
└── launch.lua
├── events
├── new-tab-button.lua
├── right-status.lua
└── tab-title.lua
├── img
├── image-20240905172247861.png
└── image-20240905172308289.png
├── screenshots
├── screenshot-1.png
└── screenshot-2.png
├── utils
├── math.lua
└── platform.lua
└── wezterm.lua
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: https://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # Unix-style newlines with a newline ending every file
7 | [*]
8 | charset = utf-8
9 | end_of_line = lf
10 | insert_final_newline = true
11 | trim_trailing_whitespace = true
12 |
13 | # For all *.sh file indent_size is 4, indent_style is space
14 | [*.sh]
15 | indent_style = space
16 | indent_size = 4
17 | max_line_length = 80
18 |
19 | # For all *.lua file indent_size is 2, indent_style is space
20 | [*.lua]
21 | indent_style = space
22 | indent_size = 2
23 |
24 | # For all *.yml and *.yaml file indent_size is 2, indent_style is space
25 | [*.{yml,yaml}]
26 | indent_style = space
27 | indent_size = 2
28 |
29 | # For file name is Dockerfile indent_size is 4, indent_style is space
30 | [Dockerfile]
31 | indent_style = space
32 | indent_size = 4
33 |
34 | # For all *.md file trim_trailing_whitespace is false
35 | [*.md]
36 | trim_trailing_whitespace = false
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /luarocks.bat
2 | /lua.bat
3 | /lua_modules
4 | /.luarocks
5 |
--------------------------------------------------------------------------------
/.luarc.json:
--------------------------------------------------------------------------------
1 | {
2 | "workspace.checkThirdParty": false
3 | }
--------------------------------------------------------------------------------
/.stylua.toml:
--------------------------------------------------------------------------------
1 | column_width = 120
2 | line_endings = "Unix"
3 | indent_type = "Spaces"
4 | indent_width = 2
5 | quote_style = "AutoPreferDouble"
6 | call_parentheses = "Always"
7 | collapse_simple_statement = "Never"
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Kevin Silvester
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |

8 |
9 |
10 | WezTerm
11 |
12 |
13 |

14 |

15 |

16 |
17 |

18 |

19 |
20 |
21 |
22 | A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
23 |
24 |
25 | User facing docs and guide at: wezterm.org
26 |
27 |
28 |
29 |
30 | # 我的WezTerm配置
31 |
32 | **截图一**
33 |
34 | 
35 |
36 | **截图二**
37 |
38 | 
39 |
40 |
41 |
42 | ## 相关链接
43 |
44 | -
45 | -
46 | -
47 | -
48 | -
49 |
50 |
51 |
52 | ## 原作者仓库
53 |
54 | -
55 |
56 |
57 |
58 | ## 前提条件
59 |
60 | **1、安装`wezterm`终端**
61 |
62 | [WezTerm终端](https://github.com/wezterm/wezterm/releases)
63 |
64 | 安装目录:C:\soft\WezTerm-windows
65 |
66 | **2、安装`nerdfont`字体**
67 |
68 | [MesloLGM Nerd Font](https://github.com/ryanoasis/nerd-fonts/blob/v3.2.1/patched-fonts/Meslo/M/Regular/MesloLGMNerdFont-Regular.ttf)
69 |
70 | [JetBrainsMono NF](https://github.com/ryanoasis/nerd-fonts/blob/v3.2.1/patched-fonts/JetBrainsMono/Ligatures/Regular/JetBrainsMonoNerdFont-Regular.ttf)
71 |
72 | 字体版本 `v3.2.1` ,注意了,版本很重要,如果某些图标弃用了或更新了,那么就需要更新字体版本,或者更新图标,**总而言之:必须让字体版本与图标对应上,否则就会出现奇怪的乱码**
73 |
74 | [图标 icon 搜索网站](https://www.nerdfonts.com/cheat-sheet)
75 |
76 |
77 |
78 | ## 使用方法
79 |
80 | 1、下载本储存库压缩包
81 |
82 | 2、解压压缩包
83 |
84 | 3、将解压的文件放入:`$HOME/.config/wezterm`目录底下
85 |
86 | Windows目录:`C:\Users\Fizz\.config\wezterm`
87 |
88 |
89 |
90 | ## 快捷键
91 |
92 | ```bash
93 | #快捷键
94 | Ctrl+shift+c --复制
95 | Ctrl+shift+v --粘贴
96 | Ctrl+shift+r --重命名标签栏
97 | Ctrl+alt+[\] --水平拆分窗格,即左右拆分
98 | Ctrl+alt+[/] --垂直拆分窗格,即上下拆分
99 | Ctrl+alt+[-] --关闭当前窗格
100 | Ctrl+alt+z --最大化/最小化当前窗格
101 | F11 --全屏
102 | Ctrl+alt+[↑] --向上扩展窗格
103 | Ctrl+alt+[↓] --向下扩展窗格
104 | Ctrl+alt+[←] --向左扩展窗格
105 | Ctrl+alt+[→] --向右扩展窗格
106 | Alt+[↑] --放大字体
107 | Alt+[↓] --缩小字体
108 | Alt+r --重置字体大小
109 | ```
110 |
111 |
112 |
113 | ## 配置右键菜单
114 |
115 | win+r 输入 regedit 打开注册表编辑器,依次展开`HKEY_CLASSES_ROOT`
116 |
117 | - 底下的 `HKEY_CLASSES_ROOT\Directory`
118 | - 底下的 `HKEY_CLASSES_ROOT\Directory\Background`
119 | - 底下的 `HKEY_CLASSES_ROOT\Directory\Background\shell`
120 | - 新建一个项 `wezterm` ,在 `wezterm` 编辑 `Icon` 数据指向wezterm安装程序图标,编辑 `(默认)` 数据为菜单名称如 `Open Wezterm Here`,
121 |
122 | 
123 |
124 | 然后右键新建一个项`command`,编辑 `(默认)` 数据:`"C:\soft\WezTerm-windows\wezterm-gui" start --no-auto-connect --cwd "%V\\"`
125 |
126 | 
127 |
128 |
129 |
130 | **完成~~~ 享受**🎉🎉🎉
131 |
132 |
--------------------------------------------------------------------------------
/backdrops/space.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QianSong1/wezterm-config/7754134ec657e03232541167be8f484f550350cf/backdrops/space.jpg
--------------------------------------------------------------------------------
/colors/custom.lua:
--------------------------------------------------------------------------------
1 | -- A slightly altered version of catppucchin mocha
2 | local mocha = {
3 | rosewater = "#f5e0dc",
4 | flamingo = "#f2cdcd",
5 | pink = "#f5c2e7",
6 | mauve = "#cba6f7",
7 | red = "#f38ba8",
8 | maroon = "#eba0ac",
9 | peach = "#fab387",
10 | yellow = "#f9e2af",
11 | green = "#a6e3a1",
12 | teal = "#94e2d5",
13 | sky = "#89dceb",
14 | sapphire = "#74c7ec",
15 | blue = "#89b4fa",
16 | lavender = "#b4befe",
17 | text = "#cdd6f4",
18 | subtext1 = "#bac2de",
19 | subtext0 = "#a6adc8",
20 | overlay2 = "#9399b2",
21 | overlay1 = "#7f849c",
22 | overlay0 = "#6c7086",
23 | surface2 = "#585b70",
24 | surface1 = "#45475a",
25 | surface0 = "#313244",
26 | base = "#1f1f28",
27 | mantle = "#181825",
28 | crust = "#11111b",
29 | }
30 |
31 | local colorscheme = {
32 | foreground = mocha.text,
33 | background = mocha.base,
34 | cursor_bg = mocha.rosewater,
35 | cursor_border = mocha.rosewater,
36 | cursor_fg = mocha.crust,
37 | selection_bg = mocha.surface2,
38 | selection_fg = mocha.text,
39 | ansi = {
40 | "#0C0C0C", -- black
41 | "#C50F1F", -- red
42 | "#13A10E", -- green
43 | "#C19C00", -- yellow
44 | "#0037DA", -- blue
45 | "#881798", -- magenta/purple
46 | "#3A96DD", -- cyan
47 | "#CCCCCC", -- white
48 | },
49 | brights = {
50 | "#767676", -- black
51 | "#E74856", -- red
52 | "#16C60C", -- green
53 | "#F9F1A5", -- yellow
54 | "#3B78FF", -- blue
55 | "#B4009E", -- magenta/purple
56 | "#61D6D6", -- cyan
57 | "#F2F2F2", -- white
58 | },
59 | tab_bar = {
60 | background = "#000000",
61 | active_tab = {
62 | bg_color = mocha.surface2,
63 | fg_color = mocha.text,
64 | },
65 | inactive_tab = {
66 | bg_color = mocha.surface0,
67 | fg_color = mocha.subtext1,
68 | },
69 | inactive_tab_hover = {
70 | bg_color = mocha.surface0,
71 | fg_color = mocha.text,
72 | },
73 | new_tab = {
74 | bg_color = mocha.base,
75 | fg_color = mocha.text,
76 | },
77 | new_tab_hover = {
78 | bg_color = mocha.mantle,
79 | fg_color = mocha.text,
80 | italic = true,
81 | },
82 | },
83 | visual_bell = mocha.surface0,
84 | indexed = {
85 | [16] = mocha.peach,
86 | [17] = mocha.rosewater,
87 | },
88 | scrollbar_thumb = mocha.surface2,
89 | split = mocha.overlay0,
90 | compose_cursor = mocha.flamingo, -- nightbuild only
91 | }
92 |
93 | return colorscheme
94 |
--------------------------------------------------------------------------------
/config/appearance.lua:
--------------------------------------------------------------------------------
1 | local wezterm = require("wezterm")
2 | local colors = require("colors.custom")
3 | -- local fonts = require('config.fonts')
4 |
5 | return {
6 | term = "xterm-256color",
7 | animation_fps = 60,
8 | max_fps = 60,
9 | front_end = "WebGpu",
10 | webgpu_power_preference = "HighPerformance",
11 |
12 | -- color scheme
13 | -- colors = colors,
14 | color_scheme = "Gruvbox dark, medium (base16)",
15 |
16 | -- background
17 | window_background_opacity = 1.00,
18 | win32_system_backdrop = "Acrylic",
19 | window_background_gradient = {
20 | colors = { "#1D261B", "#261A25" },
21 | -- Specifices a Linear gradient starting in the top left corner.
22 | orientation = { Linear = { angle = -45.0 } },
23 | },
24 | background = {
25 | {
26 | source = { File = wezterm.config_dir .. "/backdrops/space.jpg" },
27 | },
28 | {
29 | source = { Color = "#1A1B26" },
30 | height = "100%",
31 | width = "100%",
32 | opacity = 0.95,
33 | },
34 | },
35 |
36 | -- scrollbar
37 | enable_scroll_bar = true,
38 | min_scroll_bar_height = "3cell",
39 | colors = {
40 | scrollbar_thumb = "#34354D",
41 | },
42 |
43 | -- tab bar
44 | enable_tab_bar = true,
45 | hide_tab_bar_if_only_one_tab = false,
46 | use_fancy_tab_bar = true,
47 | tab_max_width = 25,
48 | show_tab_index_in_tab_bar = true,
49 | switch_to_last_active_tab_when_closing_tab = true,
50 |
51 | -- cursor
52 | default_cursor_style = "BlinkingBlock",
53 | cursor_blink_ease_in = "Constant",
54 | cursor_blink_ease_out = "Constant",
55 | cursor_blink_rate = 700,
56 |
57 | -- window
58 | adjust_window_size_when_changing_font_size = false,
59 | window_decorations = "INTEGRATED_BUTTONS|RESIZE",
60 | integrated_title_button_style = "Windows",
61 | integrated_title_button_color = "auto",
62 | integrated_title_button_alignment = "Right",
63 | initial_cols = 120,
64 | initial_rows = 24,
65 | window_padding = {
66 | left = 5,
67 | right = 10,
68 | top = 12,
69 | bottom = 7,
70 | },
71 | window_close_confirmation = "AlwaysPrompt",
72 | window_frame = {
73 | active_titlebar_bg = "#0F2536",
74 | inactive_titlebar_bg = "#0F2536",
75 | -- font = fonts.font,
76 | -- font_size = fonts.font_size,
77 | },
78 | inactive_pane_hsb = { saturation = 1.0, brightness = 1.0 },
79 | }
80 |
--------------------------------------------------------------------------------
/config/bindings.lua:
--------------------------------------------------------------------------------
1 | local wezterm = require("wezterm")
2 | local platform = require("utils.platform")()
3 | local act = wezterm.action
4 |
5 | local mod = {}
6 |
7 | if platform.is_mac then
8 | mod.SUPER = "SUPER"
9 | mod.SUPER_REV = "SUPER|CTRL"
10 | elseif platform.is_win or platform.is_linux then
11 | mod.SUPER = "ALT" -- to not conflict with Windows key shortcuts
12 | mod.SUPER_REV = "ALT|CTRL"
13 | end
14 |
15 | local keys = {
16 | -- misc/useful --
17 | { key = "F1", mods = "NONE", action = "ActivateCopyMode" },
18 | { key = "F2", mods = "NONE", action = act.ActivateCommandPalette },
19 | { key = "F3", mods = "NONE", action = act.ShowLauncher },
20 | { key = "F4", mods = "NONE", action = act.ShowTabNavigator },
21 | { key = "F11", mods = "NONE", action = act.ToggleFullScreen },
22 | { key = "F12", mods = "NONE", action = act.ShowDebugOverlay },
23 | { key = "f", mods = mod.SUPER, action = act.Search({ CaseInSensitiveString = "" }) },
24 |
25 | -- copy/paste --
26 | { key = "c", mods = "CTRL|SHIFT", action = act.CopyTo("Clipboard") },
27 | { key = "v", mods = "CTRL|SHIFT", action = act.PasteFrom("Clipboard") },
28 |
29 | -- tabs --
30 | -- tabs: spawn+close
31 | { key = "t", mods = mod.SUPER, action = act.SpawnTab("DefaultDomain") },
32 | { key = "t", mods = mod.SUPER_REV, action = act.SpawnTab({ DomainName = "WSL:Ubuntu" }) },
33 | { key = "w", mods = mod.SUPER_REV, action = act.CloseCurrentTab({ confirm = false }) },
34 |
35 | -- tabs: navigation
36 | { key = "[", mods = mod.SUPER, action = act.ActivateTabRelative(-1) },
37 | { key = "]", mods = mod.SUPER, action = act.ActivateTabRelative(1) },
38 | { key = "[", mods = mod.SUPER_REV, action = act.MoveTabRelative(-1) },
39 | { key = "]", mods = mod.SUPER_REV, action = act.MoveTabRelative(1) },
40 |
41 | -- window --
42 | -- spawn windows
43 | { key = "n", mods = mod.SUPER, action = act.SpawnWindow },
44 |
45 | -- panes --
46 | -- panes: split panes
47 | {
48 | key = [[/]],
49 | mods = mod.SUPER_REV,
50 | action = act.SplitVertical({ domain = "CurrentPaneDomain" }),
51 | },
52 | {
53 | key = [[\]],
54 | mods = mod.SUPER_REV,
55 | action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }),
56 | },
57 | {
58 | key = [[-]],
59 | mods = mod.SUPER_REV,
60 | action = act.CloseCurrentPane({ confirm = true }),
61 | },
62 |
63 | -- panes: zoom+close pane
64 | { key = "z", mods = mod.SUPER_REV, action = act.TogglePaneZoomState },
65 | { key = "w", mods = mod.SUPER, action = act.CloseCurrentPane({ confirm = false }) },
66 |
67 | -- panes: navigation
68 | { key = "k", mods = mod.SUPER_REV, action = act.ActivatePaneDirection("Up") },
69 | { key = "j", mods = mod.SUPER_REV, action = act.ActivatePaneDirection("Down") },
70 | { key = "h", mods = mod.SUPER_REV, action = act.ActivatePaneDirection("Left") },
71 | { key = "l", mods = mod.SUPER_REV, action = act.ActivatePaneDirection("Right") },
72 |
73 | -- panes: resize
74 | { key = "UpArrow", mods = mod.SUPER_REV, action = act.AdjustPaneSize({ "Up", 1 }) },
75 | { key = "DownArrow", mods = mod.SUPER_REV, action = act.AdjustPaneSize({ "Down", 1 }) },
76 | { key = "LeftArrow", mods = mod.SUPER_REV, action = act.AdjustPaneSize({ "Left", 1 }) },
77 | { key = "RightArrow", mods = mod.SUPER_REV, action = act.AdjustPaneSize({ "Right", 1 }) },
78 |
79 | -- fonts --
80 | -- fonts: resize
81 | { key = "UpArrow", mods = mod.SUPER, action = act.IncreaseFontSize },
82 | { key = "DownArrow", mods = mod.SUPER, action = act.DecreaseFontSize },
83 | { key = "r", mods = mod.SUPER, action = act.ResetFontSize },
84 |
85 | -- key-tables --
86 | -- resizes fonts
87 | {
88 | key = "f",
89 | mods = "LEADER",
90 | action = act.ActivateKeyTable({
91 | name = "resize_font",
92 | one_shot = false,
93 | timemout_miliseconds = 1000,
94 | }),
95 | },
96 | -- resize panes
97 | {
98 | key = "p",
99 | mods = "LEADER",
100 | action = act.ActivateKeyTable({
101 | name = "resize_pane",
102 | one_shot = false,
103 | timemout_miliseconds = 1000,
104 | }),
105 | },
106 | -- rename tab bar
107 | {
108 | key = "R",
109 | mods = "CTRL|SHIFT",
110 | action = act.PromptInputLine({
111 | description = "Enter new name for tab",
112 | action = wezterm.action_callback(function(window, pane, line)
113 | -- line will be `nil` if they hit escape without entering anything
114 | -- An empty string if they just hit enter
115 | -- Or the actual line of text they wrote
116 | if line then
117 | window:active_tab():set_title(line)
118 | end
119 | end),
120 | }),
121 | },
122 | }
123 |
124 | local key_tables = {
125 | resize_font = {
126 | { key = "k", action = act.IncreaseFontSize },
127 | { key = "j", action = act.DecreaseFontSize },
128 | { key = "r", action = act.ResetFontSize },
129 | { key = "Escape", action = "PopKeyTable" },
130 | { key = "q", action = "PopKeyTable" },
131 | },
132 | resize_pane = {
133 | { key = "k", action = act.AdjustPaneSize({ "Up", 1 }) },
134 | { key = "j", action = act.AdjustPaneSize({ "Down", 1 }) },
135 | { key = "h", action = act.AdjustPaneSize({ "Left", 1 }) },
136 | { key = "l", action = act.AdjustPaneSize({ "Right", 1 }) },
137 | { key = "Escape", action = "PopKeyTable" },
138 | { key = "q", action = "PopKeyTable" },
139 | },
140 | }
141 |
142 | local mouse_bindings = {
143 | -- Ctrl-click will open the link under the mouse cursor
144 | {
145 | event = { Up = { streak = 1, button = "Left" } },
146 | mods = "CTRL",
147 | action = act.OpenLinkAtMouseCursor,
148 | },
149 | -- Move mouse will only select text and not copy text to clipboard
150 | {
151 | event = { Down = { streak = 1, button = "Left" } },
152 | mods = "NONE",
153 | action = act.SelectTextAtMouseCursor("Cell"),
154 | },
155 | {
156 | event = { Up = { streak = 1, button = "Left" } },
157 | mods = "NONE",
158 | action = act.ExtendSelectionToMouseCursor("Cell"),
159 | },
160 | {
161 | event = { Drag = { streak = 1, button = "Left" } },
162 | mods = "NONE",
163 | action = act.ExtendSelectionToMouseCursor("Cell"),
164 | },
165 | -- Triple Left click will select a line
166 | {
167 | event = { Down = { streak = 3, button = "Left" } },
168 | mods = "NONE",
169 | action = act.SelectTextAtMouseCursor("Line"),
170 | },
171 | {
172 | event = { Up = { streak = 3, button = "Left" } },
173 | mods = "NONE",
174 | action = act.SelectTextAtMouseCursor("Line"),
175 | },
176 | -- Double Left click will select a word
177 | {
178 | event = { Down = { streak = 2, button = "Left" } },
179 | mods = "NONE",
180 | action = act.SelectTextAtMouseCursor("Word"),
181 | },
182 | {
183 | event = { Up = { streak = 2, button = "Left" } },
184 | mods = "NONE",
185 | action = act.SelectTextAtMouseCursor("Word"),
186 | },
187 | -- Turn on the mouse wheel to scroll the screen
188 | {
189 | event = { Down = { streak = 1, button = { WheelUp = 1 } } },
190 | mods = "NONE",
191 | action = act.ScrollByCurrentEventWheelDelta,
192 | },
193 | {
194 | event = { Down = { streak = 1, button = { WheelDown = 1 } } },
195 | mods = "NONE",
196 | action = act.ScrollByCurrentEventWheelDelta,
197 | },
198 | }
199 |
200 | return {
201 | disable_default_key_bindings = true,
202 | disable_default_mouse_bindings = true,
203 | leader = { key = "Space", mods = "CTRL|SHIFT" },
204 | keys = keys,
205 | key_tables = key_tables,
206 | mouse_bindings = mouse_bindings,
207 | }
208 |
--------------------------------------------------------------------------------
/config/domains.lua:
--------------------------------------------------------------------------------
1 | return {
2 | -- ref: https://wezfurlong.org/wezterm/config/lua/SshDomain.html
3 | ssh_domains = {
4 | {
5 | -- The connection is an ssh connection, don't use any multiplexing.
6 | multiplexing = "None",
7 |
8 | -- The name of this specific domain. Must be unique amongst
9 | name = "Kali-linux",
10 |
11 | -- identifies the host:port pair of the remote server
12 | -- Can be a DNS name or an IP address with an optional
13 | -- ":port" on the end.
14 | remote_address = "192.168.44.147:22",
15 |
16 | -- Whether agent auth should be disabled.
17 | -- Set to true to disable it.
18 | -- no_agent_auth = false,
19 |
20 | -- The username to use for authenticating with the remote host
21 | username = "kali",
22 |
23 | -- Specify a SSH connection authentication file
24 | -- Default authentication file is "~/.ssh/id_rsa"
25 | ssh_option = {
26 | identityfile = "C:\\Users\\Fizz\\.ssh\\id_rsa",
27 | },
28 | },
29 | {
30 | -- The connection is an ssh connection, don't use any multiplexing.
31 | multiplexing = "None",
32 |
33 | -- The name of this specific domain. Must be unique amongst
34 | name = "Alma-linux",
35 |
36 | -- identifies the host:port pair of the remote server
37 | -- Can be a DNS name or an IP address with an optional
38 | -- ":port" on the end.
39 | remote_address = "host.myalmalinux.com:22",
40 |
41 | -- Whether agent auth should be disabled.
42 | -- Set to true to disable it.
43 | -- no_agent_auth = false,
44 |
45 | -- The username to use for authenticating with the remote host
46 | username = "root",
47 |
48 | -- Specify a SSH connection authentication file
49 | -- Default authentication file is "~/.ssh/id_rsa"
50 | ssh_option = {
51 | identityfile = "C:\\Users\\Fizz\\.ssh\\id_rsa",
52 | },
53 | },
54 | },
55 |
56 | -- ref: https://wezfurlong.org/wezterm/multiplexing.html#unix-domains
57 | unix_domains = {},
58 |
59 | -- ref: https://wezfurlong.org/wezterm/config/lua/WslDomain.html
60 | wsl_domains = {
61 | {
62 | name = "WSL:Ubuntu",
63 | distribution = "Ubuntu",
64 | username = "kevin",
65 | default_cwd = "/home/kevin",
66 | default_prog = { "fish" },
67 | },
68 | },
69 | }
70 |
--------------------------------------------------------------------------------
/config/fonts.lua:
--------------------------------------------------------------------------------
1 | local wezterm = require("wezterm")
2 | local platform = require("utils.platform")
3 |
4 | local font = "JetBrainsMono NF"
5 | local font_size = platform().is_mac and 12 or 9
6 |
7 | return {
8 | font = wezterm.font(font),
9 | font_size = font_size,
10 |
11 | --ref: https://wezfurlong.org/wezterm/config/lua/config/freetype_pcf_long_family_names.html#why-doesnt-wezterm-use-the-distro-freetype-or-match-its-configuration
12 | freetype_load_target = "Normal", ---@type 'Normal'|'Light'|'Mono'|'HorizontalLcd'
13 | freetype_render_target = "Normal", ---@type 'Normal'|'Light'|'Mono'|'HorizontalLcd'
14 | }
15 |
--------------------------------------------------------------------------------
/config/general.lua:
--------------------------------------------------------------------------------
1 | return {
2 | -- behaviours
3 | automatically_reload_config = true,
4 | check_for_updates = false,
5 | exit_behavior = "CloseOnCleanExit", -- if the shell program exited with a successful status
6 | status_update_interval = 1000,
7 |
8 | -- scrollbar
9 | scrollback_lines = 5000,
10 |
11 | -- paste behaviours
12 | canonicalize_pasted_newlines = "CarriageReturn",
13 |
14 | hyperlink_rules = {
15 | -- Matches: a URL in parens: (URL)
16 | {
17 | regex = "\\((\\w+://\\S+)\\)",
18 | format = "$1",
19 | highlight = 1,
20 | },
21 | -- Matches: a URL in brackets: [URL]
22 | {
23 | regex = "\\[(\\w+://\\S+)\\]",
24 | format = "$1",
25 | highlight = 1,
26 | },
27 | -- Matches: a URL in curly braces: {URL}
28 | {
29 | regex = "\\{(\\w+://\\S+)\\}",
30 | format = "$1",
31 | highlight = 1,
32 | },
33 | -- Matches: a URL in angle brackets:
34 | {
35 | regex = "<(\\w+://\\S+)>",
36 | format = "$1",
37 | highlight = 1,
38 | },
39 | -- Then handle URLs not wrapped in brackets
40 | {
41 | regex = "\\b\\w+://\\S+[)/a-zA-Z0-9-]+",
42 | format = "$0",
43 | },
44 | -- implicit mailto link
45 | {
46 | regex = "\\b\\w+@[\\w-]+(\\.[\\w-]+)+\\b",
47 | format = "mailto:$0",
48 | },
49 | },
50 | }
51 |
--------------------------------------------------------------------------------
/config/init.lua:
--------------------------------------------------------------------------------
1 | local wezterm = require("wezterm")
2 |
3 | ---@class Config
4 | ---@field options table
5 | local Config = {}
6 |
7 | ---Initialize Config
8 | ---@return Config
9 | function Config:init()
10 | local o = {}
11 | self = setmetatable(o, { __index = Config })
12 | self.options = {}
13 | return o
14 | end
15 |
16 | ---Append to `Config.options`
17 | ---@param new_options table new options to append
18 | ---@return Config
19 | function Config:append(new_options)
20 | for k, v in pairs(new_options) do
21 | if self.options[k] ~= nil then
22 | wezterm.log_warn(
23 | 'Duplicate config option detected: ',
24 | { old = self.options[k], new = new_options[k] }
25 | )
26 | goto continue
27 | end
28 | self.options[k] = v
29 | ::continue::
30 | end
31 | return self
32 | end
33 |
34 | return Config
35 |
--------------------------------------------------------------------------------
/config/launch.lua:
--------------------------------------------------------------------------------
1 | local platform = require("utils.platform")()
2 |
3 | local options = {
4 | default_prog = {},
5 | launch_menu = {},
6 | }
7 |
8 | if platform.is_win then
9 | options.default_prog = { "powershell" }
10 | options.launch_menu = {
11 | { label = " PowerShell v1", args = { "powershell" } },
12 | { label = " PowerShell v7", args = { "pwsh" } },
13 | { label = " Cmd", args = { "cmd" } },
14 | { label = " Nushell", args = { "nu" } },
15 | {
16 | label = " GitBash",
17 | args = { "C:\\soft\\Git\\bin\\bash.exe" },
18 | },
19 | {
20 | label = " AlmaLinux",
21 | args = { "ssh", "kali@192.168.44.147", "-p", "22" },
22 | },
23 | }
24 | elseif platform.is_mac then
25 | options.default_prog = { "/opt/homebrew/bin/fish", "--login" }
26 | options.launch_menu = {
27 | { label = " Bash", args = { "bash", "--login" } },
28 | { label = " Fish", args = { "/opt/homebrew/bin/fish", "--login" } },
29 | { label = " Nushell", args = { "/opt/homebrew/bin/nu", "--login" } },
30 | { label = " Zsh", args = { "zsh", "--login" } },
31 | }
32 | elseif platform.is_linux then
33 | options.default_prog = { "bash", "--login" }
34 | options.launch_menu = {
35 | { label = " Bash", args = { "bash", "--login" } },
36 | { label = " Fish", args = { "/opt/homebrew/bin/fish", "--login" } },
37 | { label = " Nushell", args = { "/opt/homebrew/bin/nu", "--login" } },
38 | { label = " Zsh", args = { "zsh", "--login" } },
39 | }
40 | end
41 |
42 | return options
43 |
--------------------------------------------------------------------------------
/events/new-tab-button.lua:
--------------------------------------------------------------------------------
1 | local wezterm = require("wezterm")
2 |
3 | local M = {}
4 |
5 | M.setup = function()
6 | wezterm.on("new-tab-button-click", function(window, pane, button, default_action)
7 | wezterm.log_info("new-tab", window, pane, button, default_action)
8 | if default_action and button == "Left" then
9 | window:perform_action(default_action, pane)
10 | end
11 |
12 | if default_action and button == "Right" then
13 | window:perform_action(
14 | wezterm.action.ShowLauncherArgs({
15 | title = " Select/Search:",
16 | flags = "FUZZY|LAUNCH_MENU_ITEMS|DOMAINS",
17 | }),
18 | pane
19 | )
20 | end
21 | return false
22 | end)
23 | end
24 |
25 | return M
26 |
--------------------------------------------------------------------------------
/events/right-status.lua:
--------------------------------------------------------------------------------
1 | local wezterm = require("wezterm")
2 | local math = require("utils.math")
3 | local M = {}
4 |
5 | M.separator_char = " ~ "
6 |
7 | M.colors = {
8 | date_fg = "#3E7FB5",
9 | date_bg = "#0F2536",
10 | battery_fg = "#B52F90",
11 | battery_bg = "#0F2536",
12 | separator_fg = "#786D22",
13 | separator_bg = "#0F2536",
14 | }
15 |
16 | M.cells = {} -- wezterm FormatItems (ref: https://wezfurlong.org/wezterm/config/lua/wezterm/format.html)
17 |
18 | ---@param text string
19 | ---@param icon string
20 | ---@param fg string
21 | ---@param bg string
22 | ---@param separate boolean
23 | M.push = function(text, icon, fg, bg, separate)
24 | table.insert(M.cells, { Foreground = { Color = fg } })
25 | table.insert(M.cells, { Background = { Color = bg } })
26 | table.insert(M.cells, { Attribute = { Intensity = "Bold" } })
27 | table.insert(M.cells, { Text = icon .. " " .. text .. " " })
28 |
29 | if separate then
30 | table.insert(M.cells, { Foreground = { Color = M.colors.separator_fg } })
31 | table.insert(M.cells, { Background = { Color = M.colors.separator_bg } })
32 | table.insert(M.cells, { Text = M.separator_char })
33 | end
34 |
35 | table.insert(M.cells, "ResetAttributes")
36 | end
37 |
38 | M.set_date = function()
39 | local date = wezterm.strftime(" %a %H:%M")
40 | M.push(date, "", M.colors.date_fg, M.colors.date_bg, true)
41 | end
42 |
43 | M.set_battery = function()
44 | -- ref: https://wezfurlong.org/wezterm/config/lua/wezterm/battery_info.html
45 | local discharging_icons = { "", "", "", "", "", "", "", "", "", "" }
46 | local charging_icons = { "", "", "", "", "", "", "", "", "", "" }
47 |
48 | local charge = ""
49 | local icon = ""
50 |
51 | for _, b in ipairs(wezterm.battery_info()) do
52 | local idx = math.clamp(math.round(b.state_of_charge * 10), 1, 10)
53 | charge = string.format("%.0f%%", b.state_of_charge * 100)
54 |
55 | if b.state == "Charging" then
56 | icon = charging_icons[idx]
57 | else
58 | icon = discharging_icons[idx]
59 | end
60 | end
61 |
62 | M.push(charge, icon, M.colors.battery_fg, M.colors.battery_bg, false)
63 | end
64 |
65 | M.setup = function()
66 | wezterm.on("update-right-status", function(window, _pane)
67 | M.cells = {}
68 | M.set_date()
69 | M.set_battery()
70 |
71 | window:set_right_status(wezterm.format(M.cells))
72 | end)
73 | end
74 |
75 | return M
76 |
--------------------------------------------------------------------------------
/events/tab-title.lua:
--------------------------------------------------------------------------------
1 | local wezterm = require("wezterm")
2 |
3 | -- Inspired by https://github.com/wez/wezterm/discussions/628#discussioncomment-1874614
4 |
5 | local GLYPH_SEMI_CIRCLE_LEFT = ""
6 | -- local GLYPH_SEMI_CIRCLE_LEFT = utf8.char(0xe0b6)
7 | local GLYPH_SEMI_CIRCLE_RIGHT = ""
8 | -- local GLYPH_SEMI_CIRCLE_RIGHT = utf8.char(0xe0b4)
9 | local GLYPH_CIRCLE = " "
10 | -- local GLYPH_CIRCLE = utf8.char(0xf111)
11 | local GLYPH_ADMIN = " "
12 | -- local GLYPH_ADMIN = utf8.char(0xfc7e)
13 |
14 | local M = {}
15 |
16 | M.cells = {}
17 |
18 | M.colors = {
19 | default = {
20 | bg = "#8C246F",
21 | fg = "#0F2536",
22 | },
23 | is_active = {
24 | bg = "#3A854B",
25 | fg = "#0F2536",
26 | },
27 |
28 | hover = {
29 | bg = "#8C246F",
30 | fg = "#0F2536",
31 | },
32 | }
33 |
34 | M.set_process_name = function(s)
35 | local a = string.gsub(s, "(.*[/\\])(.*)", "%2")
36 | return a:gsub("%.exe$", "")
37 | end
38 |
39 | M.set_title = function(process_name, static_title, active_title, max_width, inset)
40 | local title
41 | inset = inset or 6
42 |
43 | if process_name:len() > 0 and static_title:len() == 0 then
44 | title = " " .. process_name .. " ~ " .. " "
45 | elseif static_title:len() > 0 then
46 | title = " " .. static_title .. " ~ " .. " "
47 | else
48 | title = " " .. active_title .. " ~ " .. " "
49 | end
50 |
51 | if title:len() > max_width - inset then
52 | local diff = title:len() - max_width + inset
53 | title = wezterm.truncate_right(title, title:len() - diff)
54 | end
55 |
56 | return title
57 | end
58 |
59 | M.check_if_admin = function(p)
60 | if p:match("^Administrator: ") then
61 | return true
62 | end
63 | return false
64 | end
65 |
66 | ---@param fg string
67 | ---@param bg string
68 | ---@param attribute table
69 | ---@param text string
70 | M.push = function(bg, fg, attribute, text)
71 | table.insert(M.cells, { Background = { Color = bg } })
72 | table.insert(M.cells, { Foreground = { Color = fg } })
73 | table.insert(M.cells, { Attribute = attribute })
74 | table.insert(M.cells, { Text = text })
75 | end
76 |
77 | M.setup = function()
78 | wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width)
79 | M.cells = {}
80 |
81 | local bg
82 | local fg
83 | local process_name = M.set_process_name(tab.active_pane.foreground_process_name)
84 | local is_admin = M.check_if_admin(tab.active_pane.title)
85 | local title = M.set_title(process_name, tab.tab_title, tab.active_pane.title, max_width, (is_admin and 8))
86 |
87 | if tab.is_active then
88 | bg = M.colors.is_active.bg
89 | fg = M.colors.is_active.fg
90 | elseif hover then
91 | bg = M.colors.hover.bg
92 | fg = M.colors.hover.fg
93 | else
94 | bg = M.colors.default.bg
95 | fg = M.colors.default.fg
96 | end
97 |
98 | local has_unseen_output = false
99 | for _, pane in ipairs(tab.panes) do
100 | if pane.has_unseen_output then
101 | has_unseen_output = true
102 | break
103 | end
104 | end
105 |
106 | -- Left semi-circle
107 | M.push(fg, bg, { Intensity = "Bold" }, GLYPH_SEMI_CIRCLE_LEFT)
108 |
109 | -- Admin Icon
110 | if is_admin then
111 | M.push(bg, fg, { Intensity = "Bold" }, " " .. GLYPH_ADMIN)
112 | end
113 |
114 | -- Title
115 | M.push(bg, fg, { Intensity = "Bold" }, " " .. title)
116 |
117 | -- Unseen output alert
118 | if has_unseen_output then
119 | M.push(bg, "#FF3B8B", { Intensity = "Bold" }, " " .. GLYPH_CIRCLE)
120 | end
121 |
122 | -- Right padding
123 | M.push(bg, fg, { Intensity = "Bold" }, " ")
124 |
125 | -- Right semi-circle
126 | M.push(fg, bg, { Intensity = "Bold" }, GLYPH_SEMI_CIRCLE_RIGHT)
127 |
128 | return M.cells
129 | end)
130 | end
131 |
132 | return M
133 |
134 | -- local CMD_ICON = utf8.char(0xe62a)
135 | -- local NU_ICON = utf8.char(0xe7a8)
136 | -- local PS_ICON = utf8.char(0xe70f)
137 | -- local ELV_ICON = utf8.char(0xfc6f)
138 | -- local WSL_ICON = utf8.char(0xf83c)
139 | -- local YORI_ICON = utf8.char(0xf1d4)
140 | -- local NYA_ICON = utf8.char(0xf61a)
141 | --
142 | -- local VIM_ICON = utf8.char(0xe62b)
143 | -- local PAGER_ICON = utf8.char(0xf718)
144 | -- local FUZZY_ICON = utf8.char(0xf0b0)
145 | -- local HOURGLASS_ICON = utf8.char(0xf252)
146 | -- local SUNGLASS_ICON = utf8.char(0xf9df)
147 | --
148 | -- local PYTHON_ICON = utf8.char(0xf820)
149 | -- local NODE_ICON = utf8.char(0xe74e)
150 | -- local DENO_ICON = utf8.char(0xe628)
151 | -- local LAMBDA_ICON = utf8.char(0xfb26)
152 | --
153 | -- local SOLID_LEFT_ARROW = utf8.char(0xe0ba)
154 | -- local SOLID_LEFT_MOST = utf8.char(0x2588)
155 | -- local SOLID_RIGHT_ARROW = utf8.char(0xe0bc)
156 | -- local ADMIN_ICON = utf8.char(0xf49c)
157 |
--------------------------------------------------------------------------------
/img/image-20240905172247861.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QianSong1/wezterm-config/7754134ec657e03232541167be8f484f550350cf/img/image-20240905172247861.png
--------------------------------------------------------------------------------
/img/image-20240905172308289.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QianSong1/wezterm-config/7754134ec657e03232541167be8f484f550350cf/img/image-20240905172308289.png
--------------------------------------------------------------------------------
/screenshots/screenshot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QianSong1/wezterm-config/7754134ec657e03232541167be8f484f550350cf/screenshots/screenshot-1.png
--------------------------------------------------------------------------------
/screenshots/screenshot-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QianSong1/wezterm-config/7754134ec657e03232541167be8f484f550350cf/screenshots/screenshot-2.png
--------------------------------------------------------------------------------
/utils/math.lua:
--------------------------------------------------------------------------------
1 | local _math = math
2 |
3 | _math.clamp = function(x, min, max)
4 | return x < min and min or (x > max and max or x)
5 | end
6 |
7 | _math.round = function(x, increment)
8 | if increment then
9 | return _math.round(x / increment) * increment
10 | end
11 | return x >= 0 and math.floor(x + 0.5) or math.ceil(x - 0.5)
12 | end
13 |
14 | return _math
15 |
--------------------------------------------------------------------------------
/utils/platform.lua:
--------------------------------------------------------------------------------
1 | local wezterm = require("wezterm")
2 |
3 | local function is_found(str, pattern)
4 | return string.find(str, pattern) ~= nil
5 | end
6 |
7 | local function platform()
8 | return {
9 | is_win = is_found(wezterm.target_triple, "windows"),
10 | is_linux = is_found(wezterm.target_triple, "linux"),
11 | is_mac = is_found(wezterm.target_triple, "apple"),
12 | }
13 | end
14 |
15 | return platform
16 |
--------------------------------------------------------------------------------
/wezterm.lua:
--------------------------------------------------------------------------------
1 | local Config = require("config")
2 |
3 | require("events.right-status").setup()
4 | require("events.tab-title").setup()
5 | require("events.new-tab-button").setup()
6 |
7 | return Config:init()
8 | :append(require("config.appearance"))
9 | :append(require("config.bindings"))
10 | :append(require("config.domains"))
11 | :append(require("config.fonts"))
12 | :append(require("config.general"))
13 | :append(require("config.launch")).options
14 |
--------------------------------------------------------------------------------