Skip to content

Instantly share code, notes, and snippets.

@spheromak
Last active January 28, 2022 06:49
Show Gist options
  • Save spheromak/0130d81b1e199f0cab28afc53fc745e2 to your computer and use it in GitHub Desktop.
Save spheromak/0130d81b1e199f0cab28afc53fc745e2 to your computer and use it in GitHub Desktop.
wezterm.lua
local wezterm = require 'wezterm';
local launch_menu = {}
local custom_colors = {}
local custom_keys = {}
-- Launch menu
if wezterm.target_triple == "x86_64-pc-windows-msvc" then
table.insert(launch_menu, {
label = "PowerShell",
args = {"powershell.exe", "-NoLogo"},
})
table.insert(launch_menu, {
label = "PowerShell(Admin)",
args = {"powershell.exe", "-NoLogo", "Start-Process", "-Verb", "runAs", "wt", "powershell.exe"},
})
-- Find installed visual studio version(s) and add their compilation
-- environment command prompts to the menu
for _, vsvers in ipairs(wezterm.glob("Microsoft Visual Studio/20*", "C:/Program Files (x86)")) do
local year = vsvers:gsub("Microsoft Visual Studio/", "")
table.insert(launch_menu, {
label = "x64 Native Tools VS " .. year,
args = {"cmd.exe", "/k", "C:/Program Files (x86)/" .. vsvers .. "/BuildTools/VC/Auxiliary/Build/vcvars64.bat"},
})
end
--[[
-- Enumerate any WSL distributions that are installed and add those to the menu
local success, wsl_list, wsl_err = wezterm.run_child_process({"wsl.exe", "-l"})
-- `wsl.exe -l` has a bug where it always outputs utf16:
-- https://github.com/microsoft/WSL/issues/4607
-- So we get to convert it
wsl_list = wezterm.utf16_to_utf8(wsl_list)
for idx, line in ipairs(wezterm.split_by_newlines(wsl_list)) do
-- Skip the first line of output; it's just a header
if idx > 1 then
-- Remove the "(Default)" marker from the default line to arrive
-- at the distribution name on its own
local distro = line:gsub(" %(Default%)", "")
-- Add an entry that will spawn into the distro with the default shell
table.insert(launch_menu, {
label = distro .. " (WSL default shell)",
args = {"wsl.exe", "--distribution", distro},
})
-- Here's how to jump directly into some other program; in this example
-- its a shell that probably isn't the default, but it could also be
-- any other program that you want to run in that environment
table.insert(launch_menu, {
label = distro .. " (WSL zsh login shell)",
args = {"wsl.exe", "--distribution", distro, "--exec", "/bin/zsh", "-l"},
})
end
end
]]--
end
custom_colors = {
tab_bar = {
-- The color of the strip that goes along the top of the window
background = "#111111",
-- The active tab is the one that has focus in the window
active_tab = {
-- The color of the background area for the tab
bg_color = "#333333",
--bg_color = "#002042",
-- The color of the text for the tab
fg_color = "#c0c0c0",
-- Specify whether you want "Half", "Normal" or "Bold" intensity for the
-- label shown for this tab.
-- The default is "Normal"
intensity = "Normal",
-- Specify whether you want "None", "Single" or "Double" underline for
-- label shown for this tab.
-- The default is "None"
underline = "None",
-- Specify whether you want the text to be italic (true) or not (false)
-- for this tab. The default is false.
italic = false,
-- Specify whether you want the text to be rendered with strikethrough (true)
-- or not for this tab. The default is false.
strikethrough = false,
},
-- Inactive tabs are the tabs that do not have focus
inactive_tab = {
bg_color = "#111111",
fg_color = "#808080",
-- The same options that were listed under the `active_tab` section above
-- can also be used for `inactive_tab`.
},
-- You can configure some alternate styling when the mouse pointer
-- moves over inactive tabs
inactive_tab_hover = {
bg_color = "#3b3052",
fg_color = "#909090",
-- italic = true,
-- The same options that were listed under the `active_tab` section above
-- can also be used for `inactive_tab_hover`.
},
-- The new tab button that let you create new tabs
new_tab = {
bg_color = "#111111",
fg_color = "#808080",
-- The same options that were listed under the `active_tab` section above
-- can also be used for `new_tab`.
},
-- You can configure some alternate styling when the mouse pointer
-- moves over the new tab button
new_tab_hover = {
bg_color = "#3b3052",
fg_color = "#909090",
italic = true,
-- The same options that were listed under the `active_tab` section above
-- can also be used for `new_tab_hover`.
}
}
}
custom_keys = {
{
key="q",
mods="ALT",
action=wezterm.action{ CloseCurrentTab={confirm=true} }
},
{
key="n",
mods="ALT",
action=wezterm.action{ SpawnTab="CurrentPaneDomain" }
},
{
key="f",
mods="ALT",
action="ToggleFullScreen"
},
{
key="v",
mods="ALT",
action=wezterm.action{SplitVertical={domain="CurrentPaneDomain"}}
},
{
key="Enter",
mods="ALT",
action=wezterm.action{SplitHorizontal={domain="CurrentPaneDomain"}}
},
{
key="h",
mods="ALT",
action=wezterm.action{ActivatePaneDirection="Left"}
},
{
key="l",
mods="ALT",
action=wezterm.action{ActivatePaneDirection="Right"}
},
{
key="j",
mods="ALT",
action=wezterm.action{ActivatePaneDirection="Down"}
},
{
key="k",
mods="ALT",
action=wezterm.action{ActivatePaneDirection="Up"}
},
{
key="w",
mods="ALT",
action=wezterm.action{CloseCurrentPane={confirm=false}}
},
{
key="z",
mods="CTRL",
action="TogglePaneZoomState"
},
}
return {
font = wezterm.font("Fira Code"),
color_scheme = "OneHalfDark",
-- pane_focus_follows_mouse = true,
launch_menu = launch_menu,
scrollback_lines = 10000,
-- set to false to disable the tab bar completely
enable_tab_bar = true,
-- set to true to hide the tab bar when there is only
-- a single tab in the window
hide_tab_bar_if_only_one_tab = false,
-- custom colors
colors = custom_colors,
-- Keys
keys = custom_keys,
default_prog = {"wsl.exe", "--distribution", "Ubuntu-20.04", "--exec", "/bin/zsh", "-l"},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment