Skip to content

Commit

Permalink
chore(wezterm): more tweaks and tab customizations
Browse files Browse the repository at this point in the history
  • Loading branch information
silveiralexf committed Jul 30, 2024
1 parent 172282f commit f65d382
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@


### [2024-07-30]
* [[172282f]](https://github.com/silveiralexf/.dotfiles/commit/172282ffc4128dcce442a80c33925966358e359f) refactor(hammerspoon): change structure and add commands (silveiralexf@gmail.com)


* [[a3750bc]](https://github.com/silveiralexf/.dotfiles/commit/a3750bcd94098384ec1964d9d766042adf2b489e) chore(nvim): add telescope media preview (silveiralexf@gmail.com)


Expand Down
2 changes: 1 addition & 1 deletion wezterm/config/appearance.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ return {
enable_tab_bar = true,
hide_tab_bar_if_only_one_tab = false,
use_fancy_tab_bar = false,
tab_max_width = 25,
tab_max_width = 45,
show_tab_index_in_tab_bar = false,
switch_to_last_active_tab_when_closing_tab = true,
tab_bar_at_bottom = true,
Expand Down
4 changes: 2 additions & 2 deletions wezterm/config/general.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ return {
scrollback_lines = 5000,

hyperlink_rules = {
-- Matches: a URL in parens: (URL)
-- Matches: a URL in parenthesis: (URL)
{
regex = '\\((\\w+://\\S+)\\)',
format = '$1',
Expand Down Expand Up @@ -37,7 +37,7 @@ return {
regex = '\\b\\w+://\\S+[)/a-zA-Z0-9-]+',
format = '$0',
},
-- implicit mailto link
-- implicit mail-to link
{
regex = '\\b\\w+@[\\w-]+(\\.[\\w-]+)+\\b',
format = 'mailto:$0',
Expand Down
16 changes: 8 additions & 8 deletions wezterm/config/init.lua
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
local wezterm = require('wezterm')

---@class Config
---@class WezTermLoader
---@field options table
local Config = {}
Config.__index = Config
local WezTermLoader = {}
WezTermLoader.__index = WezTermLoader

---Initialize Config
---@return Config
function Config:init()
---@return WezTermLoader
function WezTermLoader:init()
local config = setmetatable({ options = {} }, self)
return config
end

---Append to `Config.options`
---@param new_options table new options to append
---@return Config
function Config:append(new_options)
---@return WezTermLoader
function WezTermLoader:append(new_options)
for k, v in pairs(new_options) do
if self.options[k] ~= nil then
wezterm.log_warn('Duplicate config option detected: ', { old = self.options[k], new = new_options[k] })
Expand All @@ -26,4 +26,4 @@ function Config:append(new_options)
end
return self
end
return Config
return WezTermLoader
7 changes: 6 additions & 1 deletion wezterm/events/right-status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ local _push = function(text, icon, fg, bg, separate)
end
end

local _set_workspace = function(active_workspace_name)
_push(active_workspace_name, '📡', colors.date_fg, colors.date_bg, false)
end

local _set_date = function()
local date = wezterm.strftime('%a %D %H:%M')
_push(date, nf.fa_calendar, colors.date_fg, colors.date_bg, true)
_push(date, '📆', colors.date_fg, colors.date_bg, true)
end

local _set_battery = function()
Expand All @@ -88,6 +92,7 @@ end
M.setup = function()
wezterm.on('update-right-status', function(window)
__cells__ = {}
_set_workspace(string.format('wokspace: %s %s', wezterm.mux.get_active_workspace(), SEPARATOR_CHAR))
_set_date()
_set_battery()

Expand Down
8 changes: 5 additions & 3 deletions wezterm/events/tab-title.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ local colors = {
hover = { bg = '#587d8c', fg = '#1c1b19' },
}

-- TODO: Needs work, pane titles are still clunky
local _set_process_name = function(s)
local a = string.gsub(s, '(.*[/\\])(.*)', '%2')
return a:gsub('%.exe$', '')
Expand All @@ -42,9 +43,9 @@ local _set_title = function(process_name, base_title, max_width, inset)
local title
inset = inset or 6

if process_name:len() == 0 or process_name == '' then
title = '' .. title
elseif process_name:len() < 4 or process_name == 'zsh' then
if process_name:len() == 0 then
title = '' .. process_name
elseif process_name:len() < 4 or process_name == 'zsh' or process_name == 'bash' then
title = '⚠️ ~ ' .. process_name
else
title = base_title
Expand All @@ -58,6 +59,7 @@ local _set_title = function(process_name, base_title, max_width, inset)
return title
end

-- TODO: Needs further work
local _check_if_admin = function(p)
if p:match('^Administrator: ') then
return true
Expand Down
4 changes: 2 additions & 2 deletions wezterm/wezterm.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local Config = require('config')
local WezTermLoader = require('config')

require('utils.backdrops'):set_files():random()

Expand All @@ -7,7 +7,7 @@ require('events.left-status').setup()
require('events.tab-title').setup()
require('events.new-tab-button').setup()

return Config:init()
return WezTermLoader:init()
:append(require('config.appearance'))
:append(require('config.bindings'))
:append(require('config.fonts'))
Expand Down

0 comments on commit f65d382

Please sign in to comment.