-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.wezterm.lua
More file actions
286 lines (242 loc) · 11.4 KB
/
.wezterm.lua
File metadata and controls
286 lines (242 loc) · 11.4 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
local wezterm = require("wezterm")
local act = wezterm.action
local rose_pine = wezterm.plugin.require('https://github.com/neapsix/wezterm').moon
function get_dirs(base_path, max_depth)
local dirs = {}
local escaped_path = base_path:gsub("'", "''")
local ps_command = string.format(
"Get-ChildItem -Path '%s' -Directory -Recurse -Depth %d -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName",
escaped_path,
max_depth - 1
)
local success, stdout, stderr = wezterm.run_child_process({
"powershell.exe",
"-NoProfile",
"-NonInteractive",
"-Command",
ps_command
})
table.insert(dirs, base_path)
if success and stdout then
for line in stdout:gmatch("[^\r\n]+") do
if line and line ~= "" and line ~= base_path then
table.insert(dirs, line)
end
end
else
wezterm.log_error("Failed to get directories: " .. (stderr or "unknown error"))
end
return dirs
end
return {
font = wezterm.font("JetBrainsMono Nerd Font", { weight = "Regular" }),
font_size = 12.5,
default_prog = { "C:/Program Files/PowerShell/7/pwsh.exe" },
term = "xterm-256color",
colors = rose_pine.colors(),
window_decorations = "RESIZE | TITLE",
window_background_opacity = 1.0,
window_padding = {
left = 0,
right = 0,
top = 0,
bottom = 0,
},
use_fancy_tab_bar = false,
hide_tab_bar_if_only_one_tab = false,
tab_bar_at_bottom = true,
tab_max_width = 32,
enable_wayland = false,
enable_scroll_bar = false,
enable_tab_bar = true,
front_end = "OpenGL",
prefer_egl = true,
animation_fps = 1,
cursor_blink_rate = 0,
max_fps = 120,
scrollback_lines = 10000,
leader = { key = "a", mods = "CTRL", timeout_milliseconds = 1000 },
keys = {
-- Pane splits (tmux-style)
{ key = '"', mods = "LEADER|SHIFT", action = act.SplitVertical { domain = "CurrentPaneDomain" } },
{ key = "%", mods = "LEADER|SHIFT", action = act.SplitHorizontal { domain = "CurrentPaneDomain" } },
{ key = "-", mods = "LEADER", action = act.SplitVertical { domain = "CurrentPaneDomain" } },
{ key = "\\", mods = "LEADER", action = act.SplitHorizontal { domain = "CurrentPaneDomain" } },
-- Quit
{ key = "q", mods = "LEADER|SHIFT", action = wezterm.action.QuitApplication },
-- Pane navigation (hjkl)
{ key = "h", mods = "LEADER", action = act.ActivatePaneDirection("Left") },
{ key = "j", mods = "LEADER", action = act.ActivatePaneDirection("Down") },
{ key = "k", mods = "LEADER", action = act.ActivatePaneDirection("Up") },
{ key = "l", mods = "LEADER", action = act.ActivatePaneDirection("Right") },
-- Pane closing
{ key = "x", mods = "LEADER", action = act.CloseCurrentPane { confirm = true } },
{ key = "z", mods = "LEADER", action = act.TogglePaneZoomState },
-- Tab management
{ key = "c", mods = "LEADER", action = act.SpawnTab "CurrentPaneDomain" },
{ key = "n", mods = "LEADER", action = act.ActivateTabRelative(1) },
{ key = "p", mods = "LEADER", action = act.ActivateTabRelative(-1) },
{ key = "1", mods = "LEADER", action = act.ActivateTab(0) },
{ key = "2", mods = "LEADER", action = act.ActivateTab(1) },
{ key = "3", mods = "LEADER", action = act.ActivateTab(2) },
{ key = "4", mods = "LEADER", action = act.ActivateTab(3) },
{ key = "5", mods = "LEADER", action = act.ActivateTab(4) },
{ key = "6", mods = "LEADER", action = act.ActivateTab(5) },
{ key = "7", mods = "LEADER", action = act.ActivateTab(6) },
{ key = "8", mods = "LEADER", action = act.ActivateTab(7) },
{ key = "9", mods = "LEADER", action = act.ActivateTab(8) },
{ key = "&", mods = "LEADER|SHIFT", action = act.CloseCurrentTab { confirm = true } },
{
key = ",",
mods = "LEADER",
action = act.PromptInputLine {
description = "Enter new name for tab",
action = wezterm.action_callback(function(window, pane, line)
if line then
window:active_tab():set_title(line)
end
end),
}
},
-- Workspace management
{ key = ")", mods = "LEADER|SHIFT", action = act.SwitchWorkspaceRelative(1) },
{ key = "(", mods = "LEADER|SHIFT", action = act.SwitchWorkspaceRelative(-1) },
{ key = "n", mods = "LEADER|CTRL", action = act.SwitchWorkspaceRelative(1) },
{ key = "p", mods = "LEADER|CTRL", action = act.SwitchWorkspaceRelative(-1) },
{ key = "s", mods = "LEADER", action = act.ShowLauncherArgs { flags = "FUZZY|WORKSPACES" } },
{
key = "m",
mods = "LEADER",
action = wezterm.action_callback(function(window, pane)
local screen = window:screen()
local dims = screen:get_dimensions()
window:set_config_overrides({
initial_cols = dims.cols,
initial_rows = dims.rows,
})
end)
},
-- Session switcher
{
key = "f",
mods = "LEADER",
action = wezterm.action_callback(function(window, pane)
local dirs = get_dirs("C:/Users/ekoulaxis/Code", 3)
wezterm.log_info("Found " .. #dirs .. " directories")
if #dirs == 0 then
wezterm.log_error("No directories found!")
return
end
local choices = {}
for _, dir in ipairs(dirs) do
table.insert(choices, { label = dir })
end
window:perform_action(
act.InputSelector {
title = "Select Project Directory",
fuzzy = true,
fuzzy_description = "Fuzzy find directory: ",
choices = choices,
action = wezterm.action_callback(function(win, p, id, label)
if not label then
wezterm.log_info("No directory selected")
return
end
wezterm.log_info("Selected directory: " .. label)
-- Extract workspace name from path
local workspace_name = label:match("([^/\\]+)$")
if workspace_name then
workspace_name = workspace_name:gsub("%.", "_"):gsub("%s", "_")
wezterm.log_info("Workspace name: " .. workspace_name)
win:perform_action(
act.SwitchToWorkspace {
name = workspace_name,
spawn = { cwd = label }
},
p
)
wezterm.time.call_after(0.5, function()
for _, mux_win in ipairs(wezterm.mux.all_windows()) do
if mux_win:get_workspace() == workspace_name then
local tabs = mux_win:tabs()
if #tabs > 0 then
tabs[1]:set_title(workspace_name)
end
end
end
end)
end
end),
},
pane
)
end)
},
-- New named workspace
{
key = "S",
mods = "LEADER|SHIFT",
action = act.PromptInputLine {
description = "New workspace name",
action = wezterm.action_callback(function(window, pane, line)
if line then
window:perform_action(
act.SwitchToWorkspace { name = line },
pane
)
end
end),
}
},
-- Reload config
{ key = "r", mods = "LEADER", action = act.ReloadConfiguration },
-- Copy mode
{ key = "[", mods = "LEADER", action = act.ActivateCopyMode },
{ key = "]", mods = "LEADER", action = act.PasteFrom "Clipboard" },
-- Detach
{ key = "d", mods = "LEADER", action = act.CloseCurrentPane { confirm = false } },
-- Command palette
{ key = ":", mods = "LEADER|SHIFT", action = act.ActivateCommandPalette },
-- Fullscreen
{ key = "f", mods = "CTRL|SHIFT", action = act.ToggleFullScreen },
},
-- Copy mode configuration
key_tables = {
copy_mode = {
{ key = "v", mods = "NONE", action = act.CopyMode "MoveToStartOfLineContent" },
{ key = "V", mods = "SHIFT", action = act.CopyMode { SetSelectionMode = "Line" } },
{ key = "v", mods = "CTRL", action = act.CopyMode { SetSelectionMode = "Block" } },
-- Vi motions
{ 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 = "w", mods = "NONE", action = act.CopyMode "MoveForwardWord" },
{ key = "b", mods = "NONE", action = act.CopyMode "MoveBackwardWord" },
{ key = "0", mods = "NONE", action = act.CopyMode "MoveToStartOfLine" },
{ key = "$", mods = "SHIFT", action = act.CopyMode "MoveToEndOfLineContent" },
{ key = "g", mods = "NONE", action = act.CopyMode "MoveToScrollbackTop" },
{ key = "G", mods = "SHIFT", action = act.CopyMode "MoveToScrollbackBottom" },
-- Copy/paste
{
key = "y",
mods = "NONE",
action = act.Multiple {
{ CopyTo = "ClipboardAndPrimarySelection" },
{ CopyMode = "Close" },
}
},
{ key = "Enter", mods = "NONE", action = act.CopyMode "MoveToStartOfNextLine" },
{ key = "Escape", mods = "NONE", action = act.CopyMode "Close" },
{ key = "q", mods = "NONE", action = act.CopyMode "Close" },
},
search_mode = {
{ key = "Enter", mods = "NONE", action = act.CopyMode "PriorMatch" },
{ key = "Escape", mods = "NONE", action = act.CopyMode "Close" },
{ key = "n", mods = "CTRL", action = act.CopyMode "NextMatch" },
{ key = "p", mods = "CTRL", action = act.CopyMode "PriorMatch" },
{ key = "r", mods = "CTRL", action = act.CopyMode "CycleMatchType" },
{ key = "u", mods = "CTRL", action = act.CopyMode "ClearPattern" },
},
},
}