1
0

All modifications at once 😼

This commit is contained in:
Gürkan 2024-01-25 22:41:12 +01:00
parent 343304dfa9
commit 0fe0168700
13 changed files with 419 additions and 182 deletions

View File

@ -1,9 +1,10 @@
# Wezterm Config
## My Wezterm Config
<img width="1280" alt="Tabs with icons showcase" src="https://user-images.githubusercontent.com/62389790/215746711-bc7abab9-97e7-4e67-9426-e612a885a17a.png">
Forked from [metafates's config](https://github.com/metafates/wezterm-config)
To install
<img width="1280" alt="Tabs with icons showcase" src="https://paste.gurkan.in/meet-foal.png">
To install:
```bash
git clone https://github.com/metafates/wezterm-config.git ~/.config/wezterm
git clone https://github.com/seqizz/wezterm-config.git ~/.config/wezterm
```

23
colors.lua Normal file
View File

@ -0,0 +1,23 @@
return {
colors = {
foreground = '#d0d0d0',
background = '#212121',
cursor_bg = '#d0d0d0',
cursor_border = '#d0d0d0',
cursor_fg = '#151515',
selection_bg = 'teal',
selection_fg = '#d0d0d0',
ansi = { '#151515', '#ac4142', '#7e8e50', '#e5b567', '#6c99bb', '#9f4e85', '#7dd6cf', '#d0d0d0' },
brights = { '#505050', '#ac4142', '#7e8e50', '#e5b567', '#6c99bb', '#9f4e85', '#7dd6cf', '#f5f5f5' },
tab_bar = {
active_tab = {
bg_color = '#313638',
fg_color = '#FFFFFF',
},
inactive_tab = {
bg_color = '#1e1e1e',
fg_color = '#71797E',
},
},
},
}

View File

@ -1,29 +1,6 @@
local wezterm = require 'wezterm'
local font_size = 18
local bold = true
local font_family = ({
'Iosevka Nerd Font Mono', -- [1]
'JetBrainsMono Nerd Font', -- [2]
'FiraCode Nerd Font Mono', -- [3]
'Photonico Code', -- [4]
'VictorMono Nerd Font', -- [5]
'Hurmit Nerd Font Mono', -- [6]
'Gintronic', -- [7]
'Monocraft', -- [8]
'Comic Mono', -- [9]
'Input Mono', -- [10]
'ComicCode Nerd Font Mono', -- [11]
})[10]
local options = {}
if bold then
options['weight'] = 'Bold'
end
local font = wezterm.font(font_family, options)
local wezterm = require('wezterm')
return {
font = font,
font_size = font_size,
font_size = 14,
font = wezterm.font("Operator Mono Lig", {weight="Book"}),
}

9
generic.lua Normal file
View File

@ -0,0 +1,9 @@
return {
scrollback_lines = 20000,
hide_tab_bar_if_only_one_tab = false,
enable_wayland = false,
selection_word_boundary = ' \t\n{[}]()"\':;=',
check_for_updates = false,
warn_about_missing_glyphs = false,
exit_behavior = 'Close',
}

112
keys-mouse.lua Normal file
View File

@ -0,0 +1,112 @@
local wezterm = require 'wezterm';
return {
keys = {
-- mux start
{ key = '-', mods = 'ALT', action = wezterm.action({ SplitVertical = { domain = 'CurrentPaneDomain' } }) },
{ key = '|', mods = 'ALT', action = wezterm.action({ SplitHorizontal = { domain = 'CurrentPaneDomain' } }) },
{ key = 'z', mods = 'ALT', action = 'TogglePaneZoomState' },
{ key = 'n', mods = 'ALT', action = wezterm.action({ SpawnTab = 'CurrentPaneDomain' }) },
{ key = 'LeftArrow', mods = 'ALT', action = wezterm.action({ ActivatePaneDirection = 'Left' }) },
{ key = 'DownArrow', mods = 'ALT', action = wezterm.action({ ActivatePaneDirection = 'Down' }) },
{ key = 'UpArrow', mods = 'ALT', action = wezterm.action({ ActivatePaneDirection = 'Up' }) },
{ key = 'RightArrow', mods = 'ALT', action = wezterm.action({ ActivatePaneDirection = 'Right' }) },
{ key = 'a', mods = 'ALT', action = wezterm.action({ AdjustPaneSize = { 'Left', 5 } }) },
{ key = 's', mods = 'ALT', action = wezterm.action({ AdjustPaneSize = { 'Down', 5 } }) },
{ key = 'w', mods = 'ALT', action = wezterm.action({ AdjustPaneSize = { 'Up', 5 } }) },
{ key = 'd', mods = 'ALT', action = wezterm.action({ AdjustPaneSize = { 'Right', 5 } }) },
{ key = '1', mods = 'ALT', action = wezterm.action.ActivateTab(0) },
{ key = '2', mods = 'ALT', action = wezterm.action.ActivateTab(1) },
{ key = '3', mods = 'ALT', action = wezterm.action.ActivateTab(2) },
{ key = '4', mods = 'ALT', action = wezterm.action.ActivateTab(3) },
{ key = '5', mods = 'ALT', action = wezterm.action.ActivateTab(4) },
{ key = '6', mods = 'ALT', action = wezterm.action.ActivateTab(5) },
{ key = '7', mods = 'ALT', action = wezterm.action.ActivateTab(6) },
{ key = '8', mods = 'ALT', action = wezterm.action.ActivateTab(7) },
{ key = '9', mods = 'ALT', action = wezterm.action.ActivateTab(8) },
{ key = 'k', mods = 'ALT', action = wezterm.action.CloseCurrentTab({ confirm = true }) },
-- mux end
-- Turn off the defaults
{ key = '=', mods = 'CTRL', action = 'DisableDefaultAssignment' },
{ key = 'RightArrow', mods = 'CTRL|SHIFT', action = 'DisableDefaultAssignment' },
{ key = 'Tab', mods = 'CTRL', action = 'DisableDefaultAssignment' },
{ key = 'Tab', mods = 'CTRL|SHIFT', action = 'DisableDefaultAssignment' },
{ key = 'Tab', mods = 'SHIFT', action = 'DisableDefaultAssignment' },
{ key = 'LeftArrow', mods = 'CTRL|SHIFT', action = 'DisableDefaultAssignment' },
{ key = 'F', mods = 'CTRL|SHIFT', action = 'DisableDefaultAssignment' },
{ key = 'P', mods = 'CTRL|SHIFT', action = 'DisableDefaultAssignment' },
-- mux start
{ key = ' ', mods = 'CTRL|SHIFT', action = 'DisableDefaultAssignment' },
{ key = 'Enter', mods = 'ALT', action = 'DisableDefaultAssignment' },
-- mux end
{ key = 'Return', mods = 'ALT', action = 'DisableDefaultAssignment' },
{ key = 'n', mods = 'SUPER', action = 'DisableDefaultAssignment' },
-- standalone start
-- {key="1", mods="ALT", action="DisableDefaultAssignment"},
-- {key="2", mods="ALT", action="DisableDefaultAssignment"},
-- {key="3", mods="ALT", action="DisableDefaultAssignment"},
-- {key="4", mods="ALT", action="DisableDefaultAssignment"},
-- {key="5", mods="ALT", action="DisableDefaultAssignment"},
-- {key="6", mods="ALT", action="DisableDefaultAssignment"},
-- {key="7", mods="ALT", action="DisableDefaultAssignment"},
-- {key="8", mods="ALT", action="DisableDefaultAssignment"},
-- {key="9", mods="ALT", action="DisableDefaultAssignment"},
--standalone end
-- Assign new
-- @Reference see above
-- {key="A", mods="ALT", action=wezterm.action_callback(
-- function(window, pane)
-- send_signal(pane, '-USR1')
-- end
-- )},
{ key = 'x', mods = 'ALT', action = 'QuickSelect' },
{ key = '+', mods = 'CTRL', action = 'IncreaseFontSize' },
{ key = '4', mods = 'CTRL', action = 'IncreaseFontSize' },
{ key = '-', mods = 'CTRL', action = 'DecreaseFontSize' },
{ key = '0', mods = 'CTRL', action = 'ResetFontSize' },
{ key = 'Delete', mods = 'SHIFT', action = wezterm.action({ PasteFrom = 'PrimarySelection' }) },
{ key = 'V', mods = 'CTRL', action = wezterm.action({ PasteFrom = 'Clipboard' }) },
-- Alt-c to "click" links without mouse
{
key = 'c',
mods = 'ALT',
action = wezterm.action.QuickSelectArgs({
label = 'open url',
patterns = {
-- A bit more proper regex for URLs, at least to clickable ones
'https?://[A-Za-z0-9$_+:/?@&,;%=.-]+',
},
action = wezterm.action_callback(function(window, pane)
local url = window:get_selection_text_for_pane(pane)
wezterm.log_info('opening: ' .. url)
wezterm.open_with(url)
end),
}),
},
-- mux reference start
-- {key="RightArrow", mods="CTRL|SHIFT", action=wezterm.action{EmitEvent="move-right"}},
-- {key="LeftArrow", mods="CTRL|SHIFT", action=wezterm.action{EmitEvent="move-left"}},
-- {key="UpArrow", mods="CTRL|SHIFT", action=wezterm.action{EmitEvent="move-up"}},
-- {key="DownArrow", mods="CTRL|SHIFT", action=wezterm.action{EmitEvent="move-down"}},
-- mux reference end
},
mouse_bindings = {
-- Change the default click behavior so that it only selects
-- text and doesn't open hyperlinks
{
event={Up={streak=1, button="Left"}},
mods="NONE",
action=wezterm.action{CompleteSelection="PrimarySelection"},
},
-- and make CTRL-Click open hyperlinks
{
event={Up={streak=1, button="Left"}},
mods="CTRL",
action="OpenLinkAtMouseCursor",
},
},
}

13
mux.lua Normal file
View File

@ -0,0 +1,13 @@
return {
unix_domains = {
{
name = 'default',
socket_path = os.getenv('HOME') .. '/.wezterm.sock',
connect_automatically = false,
},
},
mux_env_remove = {
'SSH_CLIENT',
'SSH_CONNECTION',
},
}

View File

@ -1,3 +0,0 @@
return {
config = '/Users/lain/.config/wezterm'
}

16
quickselect.lua Normal file
View File

@ -0,0 +1,16 @@
return {
disable_default_quick_select_patterns = true,
quick_select_patterns = {
'https?://[^"\' ]+', -- url
'sha256-\\S{44}', -- sha256 another
'[0-9a-f]{7,40}', -- sha1
'sha256:[A-Za-z0-9]{52}', -- sha256
'[a-z0-9-]+.[a-z0-9]+.[a-z0-9]+.[a-z0-9]+ ', -- inno FQDN
'[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9.-]+', -- simple e-mail
'\'(\\S[^\']*\\S)\'', -- single quoted text
'"(\\S[^"]*\\S)"', -- double quoted text
'~?/?[a-zA-Z0-9_/.-]+', -- path
'~> (.*)', -- stuff after ~> because that is the prompt
'%s(.*)%s', -- anything else covered with whitespace
},
}

View File

@ -3,68 +3,74 @@
local M = {}
local wezterm = require 'wezterm'
local wezterm = require('wezterm')
local utils = require('utils')
--- @param battery battery state of charge, from 0.00 to 1.00
--- @return string
local function render_battery(battery)
--- @type table<string, string>
local icons = wezterm.nerdfonts
local percent = battery.state_of_charge
local formatted_percent = string.format('%.0f%%', percent * 100)
--- @type table<string, string>
local icons = wezterm.nerdfonts
local percent = battery.state_of_charge
local formatted_percent = string.format('%.0f%%', percent * 100)
local get_icon = function()
local prefix = 'mdi_battery'
if battery.state == 'Charging' then
return icons[prefix .. '_charging']
end
local get_icon = function()
local prefix = 'md_battery'
if battery.state == 'Charging' then
return icons[prefix .. '_charging']
end
--- @type string
local icon_name
--- @type string
local icon_name
if percent == 1 then
icon_name = prefix
else
local suffix = math.max(1, math.ceil(percent * 10)) .. '0'
icon_name = prefix .. '_' .. suffix
end
if percent == 1 then
icon_name = prefix
else
local suffix = math.max(1, math.ceil(percent * 10)) .. '0'
icon_name = prefix .. '_' .. suffix
end
local color = percent <= 0.1 and 'Red' or 'Green'
return wezterm.format {
{ Foreground = { AnsiColor = color } },
{ Text = icons[icon_name] }
}
end
local color = percent <= 0.1 and 'Red' or 'Green'
return wezterm.format({
{ Foreground = { AnsiColor = color } },
{ Text = icons[icon_name] },
})
end
return string.format('%s %s', get_icon(), formatted_percent)
return string.format('%s %s', get_icon(), formatted_percent)
end
local function update_right_status(window)
-- "Wed Mar 3 08:14"
--- @type string
local date = wezterm.strftime '%a %b %-d %H:%M'
-- "Wed Mar 3 08:14"
--- @type string
local date = wezterm.strftime('%a %b %-d %H:%M')
--- @type string
local tilde = wezterm.format {
{ Foreground = { AnsiColor = 'Fuchsia' } },
{ Text = '~' }
}
--- @type string
local tilde = wezterm.format({
{ Foreground = { AnsiColor = 'Fuchsia' } },
{ Text = '~' },
})
--- @type string
local battery
--- @type string
local hostname = wezterm.format({
{ Background = { AnsiColor = 'Grey' } },
{ Foreground = { AnsiColor = 'White' } },
{ Text = string.format(' %s ', wezterm.hostname()) },
})
for _, b in ipairs(wezterm.battery_info()) do
battery = render_battery(b)
end
--- @type string
local battery
local status = string.format('%s %s %s ', battery, tilde, date)
window:set_right_status(wezterm.format {
{ Text = status }
})
for _, b in ipairs(wezterm.battery_info()) do
battery = render_battery(b)
end
local status = string.format('%s %s %s %s %s ', battery, tilde, date, tilde, hostname)
window:set_right_status(wezterm.format({
{ Text = status },
}))
end
function M.enable()
wezterm.on('update-right-status', update_right_status)
end
function M.enable() wezterm.on('update-right-status', update_right_status) end
return M

223
tab.lua
View File

@ -1,102 +1,165 @@
local wezterm = require 'wezterm'
local utils = require 'utils'
local wezterm = require('wezterm')
local utils = require('utils')
local CONFIG = {
padding = 1,
use_icons = true,
colorize_icons = false,
padding = 1,
use_icons = true,
use_icon_colors = true,
}
local function numberStyle(number, script)
local scripts = {
superscript = {
'',
'¹',
'²',
'³',
'',
'',
'',
'',
'',
'',
},
subscript = {
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
},
}
local numbers = scripts[script]
local number_string = tostring(number)
local result = ''
for i = 1, #number_string do
local char = number_string:sub(i, i)
local num = tonumber(char)
if num then
result = result .. numbers[num + 1]
else
result = result .. char
end
end
return result
end
--- @type table<number, string>
local tab_icons = {}
local function ansi(c)
return { AnsiColor = c }
end
local function ansi(c) return { AnsiColor = c } end
local function css(c)
return { Color = c }
end
local function css(c) return { Color = c } end
--- @type string
local sep = wezterm.format({
{ Foreground = { AnsiColor = 'Fuchsia' } },
{ Text = '' },
})
local icon_variants = utils.map({
{ 'cod_telescope', ansi('Teal') },
{ 'dev_coda', css('#3A5F0B') },
'dev_onedrive',
'fa_bath',
'fa_bug',
'fa_eye',
'fa_flask',
'fa_fort_awesome',
{ 'fa_magic', css('#7fcedc') },
{ 'fa_magnet', ansi('Grey') },
'fa_microchip',
'fa_plane',
{ 'fa_snowflake_o', css('#002553') },
'fa_subway',
{ 'fa_usd', css('#118C4F') },
{ 'fae_apple_fruit', css('#4CBB17') },
{ 'fae_biohazard', css('#EADF0C') },
{ 'fae_carot', css('#F88017') },
{ 'fae_cherry', ansi('Red') },
{ 'fae_crown', css('#ffd700') },
{ 'fae_comet', css('#61667D') },
'fae_dna',
{ 'fae_donut', css('#FAAFBE') },
{ 'fae_ice_cream', css('#FDB6D0') },
'fae_popcorn',
'fae_poison',
{ 'fae_planet', css('#A49B72') },
{ 'fae_ruby', css('#E0115F') },
{ 'fae_tooth', ansi('White') },
{ 'linux_ferris', css('#F13408') },
{ 'mdi_basketball', css('#F88158') },
{ 'mdi_clover', css('#3EA055') },
{ 'mdi_currency_eth', css('#7095F7') },
{ 'mdi_ghost', ansi('White') }
{ 'dev_coda', css('#3A5F0B') },
'dev_onedrive',
{ 'linux_awesome', ansi('Teal') },
'fa_bath',
'fa_bug',
'fa_eye',
'fae_floppy',
{ 'fa_eur', ansi('Yellow') },
'fa_flask',
'fa_fort_awesome',
{ 'fa_magic', css('#7fcedc') },
{ 'fa_magnet', ansi('Purple') },
'fa_microchip',
{ 'fa_plane', ansi('Blue') },
{ 'fa_snowflake_o', css('#002553') },
'fa_subway',
{ 'fa_usd', css('#118C4F') },
{ 'fae_apple_fruit', css('#4CBB17') },
{ 'fae_biohazard', css('#EADF0C') },
{ 'fae_carot', css('#F88017') },
{ 'fae_cherry', ansi('Red') },
{ 'md_hammer_sickle', ansi('Red') },
{ 'fae_comet', css('#61667D') },
{ 'fae_dna', css('#F88017') },
{ 'fae_donut', css('#FAAFBE') },
'fae_popcorn',
'fae_poison',
{'linux_nixos', css('#7095F7')},
'linux_gentoo',
{ 'fae_radioactive', css('#A49B72') },
{ 'fae_ruby', css('#E0115F') },
{ 'fae_tooth', ansi('White') },
'linux_tux',
{ 'md_basketball', css('#F88158') },
{ 'md_clover', css('#3EA055') },
{ 'md_currency_eth', css('#7095F7') },
{ 'md_ghost', ansi('White') },
}, function(i)
if type(i) == 'string' then
return wezterm.nerdfonts[i]
end
if type(i) == 'string' then
return wezterm.nerdfonts[i]
end
if type(i) == 'table' then
if CONFIG.use_icon_colors then
return wezterm.format {
{ Foreground = i[2] },
{ Text = wezterm.nerdfonts[i[1]] },
}
else
return wezterm.nerdfonts[i[1]]
end
end
if type(i) == 'table' then
if CONFIG.use_icon_colors then
return wezterm.format({
{ Foreground = i[2] },
{ Text = wezterm.nerdfonts[i[1]] },
})
else
return wezterm.nerdfonts[i[1]]
end
end
error('unexpected type')
error('unexpected type')
end)
wezterm.on(
'format-tab-title',
function(tab)
-- start indexing tabs from 1
local index = tab.tab_index + 1
local id = tab.tab_id
local pad = string.rep(' ', CONFIG.padding)
function tab_title(tab_info)
local title = tab_info.tab_title
-- if the tab title is explicitly set, take that
if title and #title > 0 then
return title
end
-- Otherwise, use the title from the active pane
-- in that tab
return string.sub(tab_info.active_pane.title, 1, 18)
end
if CONFIG.use_icons then
if tab_icons[id] == nil then
tab_icons[id] = icon_variants[math.random(#icon_variants)]
end
wezterm.on('format-tab-title', function(tab)
-- start indexing tabs from 1
local index = tab.tab_index + 1
local id = tab.tab_id
local pad = string.rep(' ', CONFIG.padding)
local icon = tab_icons[id]
return string.format('%s%s %d%s', pad, icon, index, pad)
end
if CONFIG.use_icons then
if tab_icons[id] == nil then
tab_icons[id] = icon_variants[math.random(#icon_variants)]
end
return string.format('%s %d %s', pad, index, pad)
end
)
local icon = tab_icons[id]
if tab.active_pane.is_zoomed then
icon = wezterm.format({
{ Background = { Color = 'DarkOrange' } },
{ Foreground = { Color = 'White' } },
{ Text = string.format('%s ', wezterm.nerdfonts['md_magnify_plus']) },
})
end
return string.format('%s%s %s%s%s', numberStyle(index, 'superscript'), icon, tab_title(tab), pad, sep)
end
return string.format('%s %d %s', pad, index, pad)
end)
return {
enable_tab_bar = true,
use_fancy_tab_bar = false,
tab_bar_at_bottom = true,
show_new_tab_button_in_tab_bar = false,
enable_tab_bar = true,
use_fancy_tab_bar = false,
tab_bar_at_bottom = true,
show_new_tab_button_in_tab_bar = false,
tab_max_width = 25,
}

View File

@ -42,4 +42,24 @@ function M.map(list, func)
return mapped
end
function M.dump(o, level)
-- a shitty pretty print implementation
level = level or 0
if type(o) == 'table' then
local l = string.rep(' ', level)
local s = l .. '{\n'
local c = l .. '}'
for k,v in pairs(o) do
if type(k) ~= 'number' then
k = '"'..tostring(k)..'"'
end
s = s .. l .. '['..tostring(k)..'] = ' .. my_utils.dump(v, level + 1) .. ',\n'
end
return s .. c
else
return tostring(o)
end
end
return M

View File

@ -1,13 +1,17 @@
local utils = require 'utils'
local utils = require('utils')
require('status').enable()
local modules = utils.map({
'window',
'font',
'theme',
'tab',
'generic',
'window',
'font',
'theme',
'tab',
'mux',
'keys-mouse',
'colors',
'quickselect',
}, utils.req)
return utils.merge(table.unpack(modules))

View File

@ -1,25 +1,21 @@
local path = require 'path'
local use_background_image = false
local padding = 0
local window_padding = {
left = padding,
right = padding,
top = padding,
bottom = padding,
left = padding,
right = padding,
top = padding,
bottom = padding,
}
local M = {
window_padding = window_padding,
window_background_image_hsb = {
brightness = 0.3
},
adjust_window_size_when_changing_font_size = false
window_decorations = "NONE",
window_close_confirmation = "NeverPrompt",
window_padding = window_padding,
window_background_image_hsb = {
brightness = 0.3,
},
window_background_opacity = 0.95,
text_background_opacity = 1.0,
adjust_window_size_when_changing_font_size = false,
}
if use_background_image then
M.window_background_image = path.config .. '/background.png'
end
return M