-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwezterm.lua
More file actions
177 lines (159 loc) · 7.25 KB
/
wezterm.lua
File metadata and controls
177 lines (159 loc) · 7.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
local wezterm = require 'wezterm'
local act = wezterm.action
local is_windows = wezterm.target_triple:find('windows') ~= nil
-- Default shell: macOS uses Homebrew zsh; on Windows launch zsh inside
-- WSL's default distro from $HOME.
-- Why the full Linuxbrew path: wsl.exe -e bypasses login shells and
-- only inherits /etc/environment's PATH, which does not include
-- /home/linuxbrew/.linuxbrew/bin. A bare `zsh` therefore would not
-- resolve. Once zsh -l starts, zsh/path.zsh adds Linuxbrew to PATH.
-- This path matches install_or_upgrade_login_shell in bin/init/wsl.sh.
local default_prog
if is_windows then
default_prog = { 'wsl.exe', '--cd', '~', '--', '/home/linuxbrew/.linuxbrew/bin/zsh', '-l' }
else
default_prog = { '/opt/homebrew/bin/zsh', '--login' }
end
-- Open links and immediately refocus WezTerm so consecutive
-- Cmd+Clicks work without needing a plain click in between.
-- NOTE: open-uri only fires for CompleteSelectionOrOpenLinkAtMouseCursor,
-- NOT for OpenLinkAtMouseCursor (see mouse_bindings below).
-- macOS only: uses /usr/bin/open and osascript. On Windows we leave
-- open-uri unhandled so WezTerm's default ShellExecute path runs.
if not is_windows then
wezterm.on('open-uri', function(_window, _pane, uri)
wezterm.run_child_process({ '/usr/bin/open', uri })
-- Refocus WezTerm after the browser steals focus.
-- Runs in a background subshell so it doesn't block the UI.
wezterm.run_child_process({
'/bin/sh', '-c',
"(sleep 0.4; osascript -e 'tell application \"WezTerm\" to activate') &",
})
return false
end)
end
local keys = {
{ mods = "CTRL", key = "q", action=wezterm.action{ SendString="\x11" } },
-- Ctrl+T で現在のディレクトリを保持して新しいタブを開く
-- OSC 7 (zsh/directory.zsh) + allow-passthrough (.tmux.conf) で CWD を取得
{ mods = "CTRL", key = "t", action = wezterm.action_callback(function(window, pane)
local cwd_url = pane:get_current_working_dir()
if cwd_url then
window:perform_action(act.SpawnCommandInNewTab {
cwd = cwd_url.file_path,
}, pane)
else
window:perform_action(act.SpawnTab 'CurrentPaneDomain', pane)
end
end)},
-- Cmd+W で現在のtmux windowを閉じる
{ mods = "CMD", key = "w", action = wezterm.action.PromptInputLine {
description = 'Close tmux window? (y/n)',
action = wezterm.action_callback(function(window, pane, line)
if line == 'y' or line == 'Y' then
-- tmux root table に割り当てた F12 を送る。
-- 文字列送信しないため、vim や実行中プロセスでも漏れない。
window:perform_action(act.SendKey { key = 'F12' }, pane)
end
end),
}},
-- tmux を利用するので今は利用していない
-- 分割
-- { mods = "LEADER", key = "v", action = wezterm.action { SplitHorizontal = { domain = "CurrentPaneDomain" } }, },
-- { mods = "LEADER", key = "s", action = wezterm.action { SplitVertical = { domain = "CurrentPaneDomain" } }, },
-- { mods = "LEADER", key = "w", action = wezterm.action.CloseCurrentPane { confirm = true } },
-- 移動
-- { mods = "LEADER", key = 'h', action = wezterm.action.ActivatePaneDirection 'Left' },
-- { mods = "LEADER", key = 'j', action = wezterm.action.ActivatePaneDirection 'Down' },
-- { mods = "LEADER", key = 'k', action = wezterm.action.ActivatePaneDirection 'Up' },
-- { mods = "LEADER", key = 'l', action = wezterm.action.ActivatePaneDirection 'Right' },
-- リサイズ
-- { mods = "LEADER|SHIFT", key = 'h', action = wezterm.action.AdjustPaneSize { 'Left', 15 } },
-- { mods = "LEADER|SHIFT", key = 'j', action = wezterm.action.AdjustPaneSize { 'Down', 15 } },
-- { mods = "LEADER|SHIFT", key = 'k', action = wezterm.action.AdjustPaneSize { 'Up', 15 } },
-- { mods = "LEADER|SHIFT", key = 'l', action = wezterm.action.AdjustPaneSize { 'Right', 15 } },
-- コピーモード
-- { mods = "LEADER", key = 'u', action = wezterm.action.ActivateCopyMode },
}
-- Windows 流儀の Ctrl+C / Ctrl+V を有効化。WezTerm の既定は Ctrl+Shift+C /
-- Ctrl+Shift+V だが、Windows ユーザーには馴染みが薄い。Ctrl+C は選択がある
-- ときだけコピーし、無ければ通常通り SIGINT を送るので vim や実行中プロセス
-- を壊さない。macOS では Cmd+C/V が既定なので Windows ターゲット時のみ。
-- Windows: Ctrl+C/V for copy/paste (macOS uses Cmd+C/V natively).
-- Ctrl+C copies when there is a terminal selection; otherwise SIGINT is
-- sent so vim/shell Ctrl+C still works. Ctrl+V always pastes — vim's
-- visual-block mode is accessible via Ctrl+Q instead.
if is_windows then
table.insert(keys, { mods = 'CTRL', key = 'c', action = wezterm.action_callback(function(window, pane)
local sel = window:get_selection_text_for_pane(pane)
if sel ~= '' then
window:perform_action(act.CopyTo 'Clipboard', pane)
window:perform_action(act.ClearSelection, pane)
else
window:perform_action(act.SendKey { key = 'c', mods = 'CTRL' }, pane)
end
end) })
table.insert(keys, { mods = 'CTRL', key = 'v', action = act.PasteFrom 'Clipboard' })
end
return {
-- $TERM value advertised to the shell (and tmux).
-- tmux's terminal-overrides in .tmux.conf match this value to enable
-- RGB (true color) and OSC 52 clipboard forwarding.
term = 'xterm-256color',
default_prog = default_prog,
window_padding = {
left = 0,
right = 0,
top = 0,
bottom = 0,
},
font = wezterm.font_with_fallback({
{family = 'JetBrains Mono', weight = 'Medium', harfbuzz_features = {'calt=0', 'clig=0', 'liga=0'} },
{family = 'JetBrains Mono', weight = 'Medium', italic = true, harfbuzz_features = {'calt=0', 'clig=0', 'liga=0'} },
{family = 'Hiragino Kaku Gothic ProN', weight = 'Medium'},
{family = 'Apple Color Emoji'},
}),
font_size = 13,
line_height = 1.2,
-- Terminal-level color palette. WezTerm uses this to render all output.
-- Keep in sync with Neovim's colorscheme (vim/color.vim) so that
-- ANSI colors and UI chrome share a consistent look.
color_scheme = 'Everforest Dark (Gogh)',
show_tab_index_in_tab_bar = false,
tab_max_width = 120,
-- Disable two-finger swipe / mouse wheel over the tab bar from switching
-- tabs. macOS trackpad swipes are easy to trigger accidentally.
mouse_wheel_scrolls_tabs = false,
window_frame = {
font_size = 12,
font = wezterm.font({ family = 'JetBrains Mono', weight = 'Medium', stretch = 'Expanded' }),
},
scrollback_lines = 100000,
max_fps = 120,
front_end = 'WebGpu',
default_cursor_style = 'SteadyBlock',
force_reverse_video_cursor = true,
audible_bell = "SystemBeep",
visual_bell = {
fade_in_function = 'EaseIn',
fade_in_duration_ms = 150,
fade_out_function = 'EaseOut',
fade_out_duration_ms = 150,
},
colors = {
visual_bell = '#202020',
},
-- https://github.com/wez/wezterm/issues/2630
-- tmux を利用するので今は利用していない
-- leader = { key = 'q', mods = 'CTRL', timeout_milliseconds = 1000 },
keys = keys,
-- Cmd bypasses tmux mouse reporting so Cmd+Click can open links
bypass_mouse_reporting_modifiers = 'SUPER',
mouse_bindings = {
{
event = { Down = { streak = 1, button = 'Right' } },
mods = 'NONE',
action = wezterm.action.PasteFrom 'Clipboard',
},
},
}