wezterm.lua
· 2.5 KiB · Lua
Raw
local wt = require("wezterm");
local TabBackground = "#000"
local TabForeground = "#aaa"
local TabForegroundActive = "#fff"
function string.split(str, sep)
local t = {}
for s in string.gmatch(str, "([^" .. sep .. "]+)") do
table.insert(t, s)
end
return t
end
function reduce_title(title)
title = title:gsub("\\", "/")
title = title:split("/")
return title[#title]
end
wt.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width)
return reduce_title(tab.active_pane.title)
end)
wt.on("format-window-title", function(tab, pane, tabs, panes, config)
return reduce_title(tab.active_pane.title)
end)
return {
color_scheme = "Monokai Remastered",
colors = {
tab_bar = {
background = TabBackground,
active_tab = {
bg_color = TabBackground,
fg_color = TabForegroundActive,
intensity = "Bold",
},
inactive_tab = {
bg_color = TabBackground,
fg_color = TabForeground,
intensity = "Normal",
},
inactive_tab_hover = {
bg_color = TabBackground,
fg_color = TabForegroundActive,
intensity = "Normal",
},
new_tab = {
bg_color = TabBackground,
fg_color = TabForeground,
},
new_tab_hover = {
bg_color = TabBackground,
fg_color = TabForegroundActive,
},
},
},
initial_cols = 100,
initial_rows = 30,
font = wt.font("等距更纱黑体 SC"),
font_size = 14,
default_cursor_style = "BlinkingBar",
cursor_blink_rate = 500,
-- hide_tab_bar_if_only_one_tab = true,
-- window_background_opacity = 0.85,
default_prog = { "D:/PowerShell/7/pwsh.exe"},
alternate_buffer_wheel_scroll_speed = 1,
window_padding = {
left = 0,
right = 0,
top = 0,
bottom = 0,
},
keys = {
{
key = "t",
mods = "CTRL",
action = wt.action {
SpawnTab = "DefaultDomain",
},
},
{
key = "V",
mods = "SHIFT|CTRL",
action = wt.action.PasteFrom 'Clipboard'
},
{
key = "RightArrow",
mods = "ALT",
action = wt.action {
ActivateTabRelative = 1,
},
},
{
key = "LeftArrow",
mods = "ALT",
action = wt.action {
ActivateTabRelative = -1,
},
},
},
mouse_bindings = {
-- Change the default click behavior so that it populates
-- the Clipboard rather the PrimarySelection.
{
event = { Up = { streak = 1, button = 'Left' } },
mods = 'NONE',
action = wt.action.CompleteSelectionOrOpenLinkAtMouseCursor 'Clipboard',
},
{
event = { Up = { streak = 1, button = 'Right' } },
mods = 'NONE',
action = wt.action.PasteFrom 'Clipboard',
}
},
}
| 1 | local wt = require("wezterm"); |
| 2 | local TabBackground = "#000" |
| 3 | local TabForeground = "#aaa" |
| 4 | local TabForegroundActive = "#fff" |
| 5 | function string.split(str, sep) |
| 6 | local t = {} |
| 7 | for s in string.gmatch(str, "([^" .. sep .. "]+)") do |
| 8 | table.insert(t, s) |
| 9 | end |
| 10 | return t |
| 11 | end |
| 12 | |
| 13 | function reduce_title(title) |
| 14 | title = title:gsub("\\", "/") |
| 15 | title = title:split("/") |
| 16 | return title[#title] |
| 17 | end |
| 18 | |
| 19 | wt.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width) |
| 20 | return reduce_title(tab.active_pane.title) |
| 21 | end) |
| 22 | wt.on("format-window-title", function(tab, pane, tabs, panes, config) |
| 23 | return reduce_title(tab.active_pane.title) |
| 24 | end) |
| 25 | return { |
| 26 | color_scheme = "Monokai Remastered", |
| 27 | colors = { |
| 28 | tab_bar = { |
| 29 | background = TabBackground, |
| 30 | active_tab = { |
| 31 | bg_color = TabBackground, |
| 32 | fg_color = TabForegroundActive, |
| 33 | intensity = "Bold", |
| 34 | }, |
| 35 | inactive_tab = { |
| 36 | bg_color = TabBackground, |
| 37 | fg_color = TabForeground, |
| 38 | intensity = "Normal", |
| 39 | }, |
| 40 | inactive_tab_hover = { |
| 41 | bg_color = TabBackground, |
| 42 | fg_color = TabForegroundActive, |
| 43 | intensity = "Normal", |
| 44 | }, |
| 45 | new_tab = { |
| 46 | bg_color = TabBackground, |
| 47 | fg_color = TabForeground, |
| 48 | }, |
| 49 | new_tab_hover = { |
| 50 | bg_color = TabBackground, |
| 51 | fg_color = TabForegroundActive, |
| 52 | }, |
| 53 | }, |
| 54 | }, |
| 55 | initial_cols = 100, |
| 56 | initial_rows = 30, |
| 57 | font = wt.font("等距更纱黑体 SC"), |
| 58 | font_size = 14, |
| 59 | default_cursor_style = "BlinkingBar", |
| 60 | cursor_blink_rate = 500, |
| 61 | -- hide_tab_bar_if_only_one_tab = true, |
| 62 | -- window_background_opacity = 0.85, |
| 63 | default_prog = { "D:/PowerShell/7/pwsh.exe"}, |
| 64 | alternate_buffer_wheel_scroll_speed = 1, |
| 65 | window_padding = { |
| 66 | left = 0, |
| 67 | right = 0, |
| 68 | top = 0, |
| 69 | bottom = 0, |
| 70 | }, |
| 71 | keys = { |
| 72 | { |
| 73 | key = "t", |
| 74 | mods = "CTRL", |
| 75 | action = wt.action { |
| 76 | SpawnTab = "DefaultDomain", |
| 77 | }, |
| 78 | }, |
| 79 | { |
| 80 | key = "V", |
| 81 | mods = "SHIFT|CTRL", |
| 82 | action = wt.action.PasteFrom 'Clipboard' |
| 83 | }, |
| 84 | { |
| 85 | key = "RightArrow", |
| 86 | mods = "ALT", |
| 87 | action = wt.action { |
| 88 | ActivateTabRelative = 1, |
| 89 | }, |
| 90 | }, |
| 91 | { |
| 92 | key = "LeftArrow", |
| 93 | mods = "ALT", |
| 94 | action = wt.action { |
| 95 | ActivateTabRelative = -1, |
| 96 | }, |
| 97 | }, |
| 98 | }, |
| 99 | mouse_bindings = { |
| 100 | -- Change the default click behavior so that it populates |
| 101 | -- the Clipboard rather the PrimarySelection. |
| 102 | { |
| 103 | event = { Up = { streak = 1, button = 'Left' } }, |
| 104 | mods = 'NONE', |
| 105 | action = wt.action.CompleteSelectionOrOpenLinkAtMouseCursor 'Clipboard', |
| 106 | }, |
| 107 | { |
| 108 | event = { Up = { streak = 1, button = 'Right' } }, |
| 109 | mods = 'NONE', |
| 110 | action = wt.action.PasteFrom 'Clipboard', |
| 111 | } |
| 112 | }, |
| 113 | } |
| 114 |