repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

refactor(wezterm): simplify tab bar

ec4f04fa95c11e0afef1b002d7f2ed983b971ba4

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (3)

wezterm/bugabinga/apps.lua

Deleted
deleted file mode 100644
1 -package.loaded['bugabinga.icons'] = nil
2 -local icon_names = require 'bugabinga.icons'
4 -local M = {}
6 -local DEFAULT_ICON = ''
8 -local SHELLS = {
9 - bash = true,
10 - fish = true,
11 - nu = true,
12 - nushell = true,
13 - sh = true,
14 - zsh = true,
17 -local ROOT_APPS = {
18 - aerc = true,
19 - btm = true,
20 - btop = true,
21 - claude = true,
22 - cmus = true,
23 - codex = true,
24 - helix = true,
25 - htop = true,
26 - kak = true,
27 - lf = true,
28 - mc = true,
29 - nano = true,
30 - neovide = true,
31 - nvim = true,
32 - opencode = true,
33 - pi = true,
34 - pwsh = true,
35 - ranger = true,
36 - ssh = true,
37 - top = true,
38 - vifm = true,
39 - vim = true,
40 - weechat = true,
41 - wsl = true,
42 - yazi = true,
43 - youtui = true,
44 - glow = true,
45 - gitu = true,
46 - presenterm = true,
49 -local LABELS = {
50 - aerc = 'Aerc',
51 - claude = 'Claude',
52 - cmus = 'Cmus',
53 - codex = 'Codex',
54 - d2 = 'D2',
55 - fd = 'fd',
56 - gh = 'GH',
57 - gitu = 'Gitu',
58 - glow = 'Glow',
59 - jar = 'JAR',
60 - javac = 'JavaC',
61 - jconsole = 'JConsole',
62 - jdb = 'JDB',
63 - jdeps = 'JDeps',
64 - jj = 'JJ',
65 - jq = 'jq',
66 - jps = 'JPS',
67 - jshell = 'JShell',
68 - mvn = 'Maven',
69 - mvnd = 'Maven',
70 - neovide = 'Neovide',
71 - nvim = 'Neovim',
72 - nu = 'Nu',
73 - opencode = 'OpenCode',
74 - pi = 'Pi',
75 - presenterm = 'Presenterm',
76 - pwsh = 'PowerShell',
77 - rg = 'rg',
78 - sd = 'sd',
79 - ssh = 'SSH',
80 - svn = 'SVN',
81 - tofu = 'OpenTofu',
82 - vim = 'Vim',
83 - ['vfp9.exe'] = 'VFP9',
84 - wsl = 'WSL',
85 - yazi = 'Yazi',
88 -local TITLE_ORDER = {
89 - 'codex', 'claude', 'opencode', 'pi',
90 - 'nvim', 'neovide', 'vim', 'helix', 'kak', 'nano',
91 - 'gitu', 'yazi', 'ranger', 'lf', 'vifm', 'mc',
92 - 'aerc', 'weechat', 'cmus', 'youtui',
93 - 'btm', 'btop', 'htop', 'top',
94 - 'presenterm', 'glow', 'ssh', 'wsl', 'pwsh',
97 -local CLAUDE_ACTIVITY_MARKERS = {
98 - '⠁', '⠂', '⠄', '⠆', '⠇', '⠋', '⠙', '⠸', '⠼', '⠴', '⠦', '⠧', '⠐',
99 - '✳', '✢', '✣', '✤', '✥', '✦', '✧', '✶', '✷', '✸', '✹', '✺', '✻', '✼', '✽', '✾', '✿',
102 -local function basename(value)
103 - if not value or value == '' then return nil end
104 - value = value:gsub('\\', '/')
105 - return value:match('([^/]+)$') or value
106 -end
108 -function M.clean_title(title)
109 - if not title or title == '' then return nil end
110 - title = title:gsub('^%s+', ''):gsub('%s+$', '')
111 - if title == '' then return nil end
112 - return title
113 -end
115 -function M.first_command(commandline)
116 - if not commandline or commandline == '' then return nil end
117 - return basename(commandline:match('^%s*([^%s|;&]+)'))
118 -end
120 -function M.detect_from_commandline(commandline)
121 - commandline = M.clean_title(commandline)
122 - if not commandline then return nil end
124 - -- Command lines are arbitrary user text. Trust only argv[0]; never classify
125 - -- from arguments like `rg claude` or task text like `Fix Claude settings`.
126 - return M.normalize(M.first_command(commandline))
127 -end
129 -function M.normalize(program)
130 - program = basename(program)
131 - if not program then return nil end
133 - program = program:lower()
134 - if program == 'vfp9.exe' then return program end
136 - program = program:gsub('%.exe$', ''):gsub('%.cmd$', ''):gsub('%.bat$', ''):gsub('%.ps1$', '')
138 - if program:find('^claude') then return 'claude' end
139 - if program:find('^codex') then return 'codex' end
140 - if program:find('^opencode') then return 'opencode' end
141 - if program:find('^pi%-') then return 'pi' end
142 - if program:find('^python') then return 'python' end
144 - if program == 'g' or program == 'lazygit' then return 'git' end
145 - if program == 'node.opti' then return 'node' end
146 - if program == 'pia' or program == 'pic' or program == 'pii' then return 'pi' end
147 - if program == 'vide' then return 'neovide' end
148 - if program == 'vim.opti' then return 'vim' end
149 - if program == 'ya' or program == 'yy' then return 'yazi' end
151 - return program
152 -end
154 -local function escape_pattern(value)
155 - return (value:gsub('([^%w])', '%%%1'))
156 -end
158 -local function starts_with(value, prefix)
159 - return value:sub(1, #prefix) == prefix
160 -end
162 -local function title_contains_program(lower_title, program)
163 - return lower_title:find('%f[%w]' .. escape_pattern(program) .. '%f[%W]') ~= nil
164 -end
166 -function M.strip_claude_activity_marker(title)
167 - title = M.clean_title(title)
168 - if not title then return nil end
170 - for _, marker in ipairs(CLAUDE_ACTIVITY_MARKERS) do
171 - if title:sub(1, #marker) == marker then
172 - return M.clean_title(title:sub(#marker + 1)) or title
173 - end
174 - end
176 - return nil
177 -end
179 -function M.detect_from_title(title)
180 - title = M.clean_title(title)
181 - if not title then return nil, false end
183 - local lower = title:lower()
184 - for _, program in ipairs(TITLE_ORDER) do
185 - if title_contains_program(lower, program) then return M.normalize(program), false end
186 - end
188 - -- UTF-8 safe: Lua pattern frontiers are byte-oriented and made Pi flaky.
189 - -- Keep after explicit app matches so Pi-hosted Codex/Claude titles render as Codex/Claude.
190 - if starts_with(title, 'π') then return 'pi', false end
192 - local stripped = M.strip_claude_activity_marker(title)
193 - if stripped then
194 - local stripped_lower = stripped:lower()
195 - for _, program in ipairs(TITLE_ORDER) do
196 - if title_contains_program(stripped_lower, program) then return M.normalize(program), true end
197 - end
198 - -- These are Claude-specific activity markers. Other agent spinners (Codex/Pi)
199 - -- are stripped in status.lua, not here, so fallback to Claude is safe here.
200 - return 'claude', true
201 - end
203 - return nil, false
204 -end
206 -function M.is_shell(program)
207 - program = M.normalize(program)
208 - return program ~= nil and SHELLS[program] == true
209 -end
211 -function M.is_root(program)
212 - program = M.normalize(program)
213 - return program ~= nil and ROOT_APPS[program] == true
214 -end
216 -function M.label(program)
217 - program = M.normalize(program)
218 - if not program then return nil end
219 - return LABELS[program] or program:gsub('%.exe$', ''):gsub('^%l', string.upper)
220 -end
222 -function M.icon_name(program)
223 - program = M.normalize(program)
224 - if not program then return nil end
225 - return icon_names[program]
226 -end
228 -function M.icon(program, nerdfonts)
229 - local icon_name = M.icon_name(program)
230 - if icon_name and nerdfonts and nerdfonts[icon_name] then return nerdfonts[icon_name] end
231 - return DEFAULT_ICON
232 -end
234 -function M.title_detail(title, program, include_shell_titles)
235 - title = M.clean_title(title)
236 - program = M.normalize(program)
237 - if not title then return nil end
238 - if not program then return title end
240 - title = M.strip_claude_activity_marker(title) or title
242 - if program == 'pi' and starts_with(title, 'π') then
243 - title = M.clean_title(title:sub(#'π' + 1):gsub('^%s*[-–—:]%s*', '')) or title
244 - -- Pi titles are usually "π - task - workspace/app". The fake tab already
245 - -- renders the app label, so drop suffixes that merely repeat the task/app.
246 - title = M.clean_title(title:gsub('%s*[-:]%s*[Pp][Ii]%s*$', '')) or title
248 - local head, tail = title:match('^(.*)%s+%-%s+(.+)$')
249 - if head and tail then
250 - local compact_head = head:lower():gsub('[^%w]', '')
251 - local compact_tail = tail:lower():gsub('[^%w]', '')
252 - local tail_is_repeat = compact_tail ~= ''
253 - and (compact_head == compact_tail
254 - or compact_head:sub(1, #compact_tail) == compact_tail
255 - or compact_head:sub(-#compact_tail) == compact_tail)
256 - if tail_is_repeat then title = M.clean_title(head) or title end
257 - end
258 - end
260 - if M.normalize(title) == program then return nil end
261 - if M.is_shell(program) and not include_shell_titles then return nil end
263 - local display = M.label(program) or program
264 - local lower = title:lower()
265 - if lower == display:lower() then return nil end
267 - local escaped_program = escape_pattern(program)
268 - local escaped_display = escape_pattern(display:lower())
269 - local detail = lower:match('^%s*' .. escaped_program .. '%s*[:%-%|—]+%s*(.+)$')
270 - or lower:match('^%s*' .. escaped_program .. '%s+(.+)$')
271 - or lower:match('^%s*' .. escaped_display .. '%s*[:%-%|—]+%s*(.+)$')
272 - or lower:match('^%s*' .. escaped_display .. '%s+(.+)$')
274 - if not detail then return title end
276 - local start_index = #title - #detail + 1
277 - return M.clean_title(title:sub(start_index))
278 -end
280 -return M

wezterm/bugabinga/icons.lua

Deleted
deleted file mode 100644
1 --- Icon map for process names in tab titles
2 --- Uses wezterm.nerdfont names: cod_*, dev_*, fa_*, md_*, seti_*
4 -return {
5 - -- shells
6 - ['bash'] = 'dev_bash',
7 - ['zsh'] = 'dev_terminal',
8 - ['fish'] = 'cod_terminal_cmd',
9 - ['sh'] = 'dev_terminal',
11 - -- other tools
12 - ['pi'] = 'md_pirate',
13 - ['claude'] = 'md_brain',
14 - ['codex'] = 'cod_sparkle',
15 - ['opencode'] = 'cod_terminal_cmd',
17 - -- editors / IDEs
18 - ['neovide'] = 'dev_vim',
19 - ['vim.opti'] = 'dev_vim',
20 - ['helix'] = 'cod_edit',
21 - ['kak'] = 'cod_edit',
22 - ['kakoune'] = 'cod_edit',
24 - -- web browsers
25 - ['firefox'] = 'dev_firefox',
26 - ['chrome'] = 'dev_chrome',
27 - ['chromium'] = 'dev_chrome',
28 - ['brave'] = 'cod_globe',
30 - -- databases
31 - ['psql'] = 'dev_postgresql',
32 - ['postgres'] = 'dev_postgresql',
33 - ['psql16'] = 'dev_postgresql',
34 - ['redis-cli'] = 'dev_redis',
35 - ['mongosh'] = 'dev_mongodb',
36 - ['sqlite3'] = 'dev_sqlite',
37 - ['mysql'] = 'dev_mysql',
39 - -- containers
40 - ['docker'] = 'dev_docker',
41 - ['podman'] = 'cod_container',
42 - ['buildah'] = 'cod_container',
44 - -- git
45 - ['git'] = 'dev_git',
46 - ['gh'] = 'dev_github',
47 - ['svn'] = 'dev_git',
48 - ['jj'] = 'dev_git',
49 - ['gitu'] = 'dev_git',
51 - -- package managers
52 - ['npm'] = 'dev_npm',
53 - ['pnpm'] = 'dev_pnpm',
54 - ['yarn'] = 'dev_yarn',
56 - -- languages / runtimes (ordered by popularity)
57 - ['node'] = 'dev_nodejs',
58 - ['node.opti'] = 'dev_nodejs',
59 - ['node16'] = 'dev_nodejs',
60 - ['node18'] = 'dev_nodejs',
61 - ['node20'] = 'dev_nodejs',
62 - ['python'] = 'dev_python',
63 - ['python3'] = 'dev_python',
64 - ['python3.11'] = 'dev_python',
65 - ['python3.12'] = 'dev_python',
66 - ['python3.13'] = 'dev_python',
67 - ['pypy'] = 'dev_python',
68 - ['ruby'] = 'dev_ruby',
69 - ['ruby3'] = 'dev_ruby',
70 - ['go1.20'] = 'dev_go',
71 - ['go1.21'] = 'dev_go',
72 - ['go1.22'] = 'dev_go',
73 - ['java'] = 'dev_java',
74 - ['javac'] = 'dev_java',
75 - ['jshell'] = 'dev_java',
76 - ['jdb'] = 'dev_java',
77 - ['jconsole'] = 'dev_java',
78 - ['jps'] = 'dev_java',
79 - ['jdeps'] = 'dev_java',
80 - ['jar'] = 'dev_java',
81 - ['keytool'] = 'dev_java',
82 - ['keytool.exe'] = 'dev_java',
83 - ['kotlin'] = 'dev_kotlin',
84 - ['gradle'] = 'dev_gradle',
85 - ['mvn'] = 'dev_java',
86 - ['mvnd'] = 'dev_java',
87 - ['php'] = 'dev_php',
88 - ['php8'] = 'dev_php',
89 - ['php8.1'] = 'dev_php',
90 - ['php8.2'] = 'dev_php',
91 - ['php8.3'] = 'dev_php',
92 - ['ghc'] = 'dev_haskell',
93 - ['elm'] = 'dev_elm',
94 - ['elixir'] = 'dev_elixir',
95 - ['mix'] = 'dev_elixir',
96 - ['iex'] = 'dev_elixir',
97 - ['beam.smp'] = 'dev_erlang',
98 - ['erl'] = 'dev_erlang',
99 - ['erl.child_setup'] = 'dev_erlang',
100 - ['julia'] = 'dev_julia',
101 - ['lua'] = 'dev_lua',
102 - ['luajit'] = 'dev_lua',
103 - ['deno'] = 'dev_denojs',
104 - ['deno.opti'] = 'dev_denojs',
105 - ['npx'] = 'dev_nodejs',
106 - ['bun'] = 'dev_bun',
107 - ['zig'] = 'dev_zig',
108 - ['ziggy'] = 'dev_zig',
109 - ['nushell'] = 'cod_terminal_cmd',
110 - ['nu'] = 'cod_terminal_cmd',
111 - ['nix'] = 'cod_terminal',
112 - ['rlwrap'] = 'cod_terminal',
113 - ['ghci'] = 'dev_haskell',
114 - ['cabal'] = 'dev_haskell',
115 - ['stack'] = 'dev_haskell',
116 - ['scala'] = 'dev_scala',
117 - ['amm'] = 'dev_scala',
119 - -- build tools
120 - ['make'] = 'cod_gear',
121 - ['cmake'] = 'cod_gear',
122 - ['ninja'] = 'cod_gear',
123 - ['just'] = 'cod_gear',
124 - ['mise'] = 'cod_gear',
125 - ['hyperfine'] = 'cod_gear',
126 - ['rake'] = 'dev_ruby',
127 - ['babashka'] = 'cod_symbol_numeric',
128 - ['bb'] = 'cod_symbol_numeric',
130 - -- version control
131 - ['vim'] = 'dev_vim',
132 - ['nvim'] = 'dev_neovim',
133 - ['vi'] = 'dev_vim',
134 - ['nano'] = 'cod_file',
135 - ['micro'] = 'cod_file',
136 - ['code'] = 'dev_vscode',
138 - -- file managers
139 - ['yazi'] = 'cod_folder',
140 - ['ranger'] = 'cod_folder',
141 - ['lf'] = 'cod_folder',
142 - ['vifm'] = 'cod_folder',
143 - ['mc'] = 'cod_folder',
145 - -- music
146 - ['cmus'] = 'cod_play',
147 - ['ncspot'] = 'cod_play',
148 - ['spotify-tui'] = 'cod_play',
150 - -- email
151 - ['neomutt'] = 'cod_mail',
152 - ['mutt'] = 'cod_mail',
153 - ['aerc'] = 'cod_mail',
155 - -- irc
156 - ['weechat'] = 'cod_chat',
157 - ['irssi'] = 'cod_chat',
158 - ['znc'] = 'cod_chat',
160 - -- news / feeds
161 - ['newsboat'] = 'cod_rss',
162 - ['heliostream'] = 'cod_rss',
164 - -- terminals
165 - ['tmux'] = 'cod_terminal_tmux',
166 - ['screen'] = 'cod_terminal',
167 - ['alacritty'] = 'cod_terminal',
168 - ['kitty'] = 'cod_terminal',
169 - ['foot'] = 'cod_terminal',
170 - ['wezterm'] = 'cod_terminal',
172 - -- system monitors
173 - ['htop'] = 'cod_heart',
174 - ['btop'] = 'cod_heart',
175 - ['bashtop'] = 'cod_heart',
176 - ['gotop'] = 'cod_heart',
177 - ['btm'] = 'cod_heart',
178 - ['top'] = 'cod_heart',
180 - -- network
181 - ['curl'] = 'cod_cloud',
182 - ['wget'] = 'cod_cloud',
183 - ['http'] = 'cod_cloud',
184 - ['xh'] = 'cod_cloud',
185 - ['wthrr'] = 'cod_cloud',
186 - ['ssh'] = 'cod_remote',
187 - ['mosh'] = 'cod_remote',
188 - ['ftp'] = 'cod_globe',
189 - ['sftp'] = 'cod_globe',
191 - -- text processing
192 - ['awk'] = 'cod_file_code',
193 - ['sed'] = 'cod_file_code',
194 - ['sd'] = 'cod_file_code',
195 - ['jq'] = 'cod_file_code',
196 - ['pandoc'] = 'cod_file_code',
197 - ['monolith'] = 'cod_file_code',
198 - ['vfp9.exe'] = 'cod_file_code',
199 - ['d2'] = 'cod_file_code',
200 - ['grep'] = 'cod_search',
201 - ['rg'] = 'cod_search',
202 - ['fd'] = 'cod_search',
204 - -- media
205 - ['ffmpeg'] = 'cod_play',
206 - ['mpv'] = 'cod_play',
207 - ['presenterm'] = 'cod_play',
208 - ['youtui'] = 'cod_play',
210 - -- passwords
211 - ['pass'] = 'cod_lock',
212 - ['gopass'] = 'cod_lock',
213 - ['bitwarden'] = 'cod_lock',
215 - -- launch menu tools
216 - ['launcher'] = 'cod_search',
217 - ['rofi'] = 'cod_search',
218 - ['dmenu'] = 'cod_search',
219 - ['wofi'] = 'cod_search',
221 - -- rust tools
222 - ['rustc'] = 'dev_rust',
223 - ['cargo'] = 'dev_rust',
224 - ['rust-analyzer'] = 'dev_rust',
226 - -- go tools
227 - ['gopls'] = 'dev_go',
228 - ['go'] = 'dev_go',
230 - -- python tools
231 - ['pylint'] = 'dev_python',
232 - ['pytest'] = 'dev_python',
233 - ['mypy'] = 'dev_python',
234 - ['ipython'] = 'dev_python',
235 - ['jupyter'] = 'dev_jupyter',
236 - ['pip'] = 'dev_python',
238 - -- devops
239 - ['terraform'] = 'dev_terraform',
240 - ['tofu'] = 'dev_terraform',
241 - ['ansible'] = 'dev_ansible',
242 - ['vagrant'] = 'dev_vagrant',
243 - ['kubectl'] = 'dev_kubernetes',
244 - ['helm'] = 'dev_helm',
245 - ['docker-compose'] = 'dev_docker',
246 - ['regctl'] = 'cod_container',
247 - ['regctl.exe'] = 'cod_container',
248 - ['ctr'] = 'cod_container',
250 - -- terminal/system helpers
251 - ['wsl'] = 'cod_terminal',
252 - ['pwsh'] = 'cod_terminal',
253 - ['gsudo'] = 'cod_lock',
254 - ['winget'] = 'cod_gear',
256 - -- docs / viewers
257 - ['glow'] = 'cod_file',
258 - ['bat'] = 'cod_file',
259 - ['tre'] = 'cod_folder',
260 - ['tree'] = 'cod_folder',
262 - -- chat
263 - ['discord'] = 'cod_chat',
264 - ['slack'] = 'cod_chat',
265 - ['teams'] = 'cod_chat',

wezterm/bugabinga/status.lua

Modified
1 1 local wez = require 'wezterm'
2 2 local bat = require 'bugabinga.battery'
4 -local DELIMITER = ' · '
5 4 local nugu_dark = require 'bugabinga.nugu.palette_dark'.palette
6 5 local nugu_light = require 'bugabinga.nugu.palette_light'.palette
7 6 local palette = nugu_dark
8 -package.loaded['bugabinga.apps'] = nil
9 -local apps = require 'bugabinga.apps'
11 -local FALLBACK_TAB_PROGRAM = 'nu'
8 +local clean = function ( value )
9 + if not value or value == '' then return nil end
10 + value = value:gsub( '^%s+', '' ):gsub( '%s+$', '' )
11 + if value == '' then return nil end
12 + return value
13 +end
13 -local tab_activity_until = {}
15 -local wall_seconds = function ()
16 - return os.time()
15 +local basename = function ( value )
16 + if not value or value == '' then return nil end
17 + value = value:gsub( '\\', '/' )
18 + return value:match( '([^/]+)$' ) or value
19 21 local use_palette_for_scheme = function ( scheme )
25 27 if ok and config then use_palette_for_scheme( config.color_scheme ) end
30 +local short_workspace = function ( name )
31 + name = clean( name ) or 'default'
32 + local home = wez.home_dir
33 + if home and name:sub( 1, #home ) == home then
34 + name = '~' .. name:sub( #home + 1 )
35 + end
36 + if name:find( '/', 1, true ) or name:find( '\\', 1, true ) then
37 + name = basename( name ) or name
38 + end
39 + return wez.truncate_right( name, 18 )
40 +end
42 +local primary_pane = function ( tab )
43 + local primary = nil
44 + for _, pane in ipairs( tab.panes or {} ) do
45 + if not primary or (pane.pane_index or 0) < (primary.pane_index or 0) then
46 + primary = pane
47 + end
48 + end
49 + return primary or tab.active_pane
50 +end
52 +local tab_text = function ( tab )
53 + local pane = primary_pane( tab )
54 + return clean( tab.tab_title )
55 + or clean( pane and pane.title )
56 + or clean( tab.active_pane and tab.active_pane.title )
57 + or 'tab'
58 +end
28 60 local zoomed = function ( pane )
29 61 local tab = pane:tab()
30 62 if not tab then return nil end
32 64 for _, info in ipairs( tab:panes_with_info() ) do
33 - if info.is_zoomed then return '🔎 Zoomed Pane' end
65 + if info.is_zoomed then return 'zoom' end
36 68 return nil
39 -local safe_user_vars = function ( pane )
40 - local ok, vars = pcall( pane.get_user_vars, pane )
41 - if ok and vars then return vars end
42 - return {}
43 -end
45 -local basename = function ( value )
46 - if not value or value == '' then return nil end
47 - value = value:gsub( '\\', '/' )
48 - return value:match( '([^/]+)$' ) or value
49 -end
51 -local program_icon = function ( program )
52 - return apps.icon( program, wez.nerdfonts )
53 -end
55 -local pulse_color = function ()
56 - return palette.ui.important_local
57 -end
59 -local busy_badge = function ()
60 - return '●', pulse_color()
61 -end
63 -local progress_badge = function ( progress )
64 - if not progress or progress == 'None' then return nil end
65 - if progress == 'Indeterminate' then return busy_badge() end
66 - if type( progress ) == 'table' and progress.Error ~= nil then return '✗', palette.error end
67 - if type( progress ) == 'table' and progress.Percentage ~= nil then return busy_badge() end
68 - return busy_badge()
69 -end
71 -local colored_badge = function ( elements, badge, color, fallback )
72 - if not badge then return end
73 - table.insert( elements, { Text = ' ' } )
74 - table.insert( elements, { Foreground = { Color = color or fallback } } )
75 - table.insert( elements, { Text = badge } )
76 - table.insert( elements, { Foreground = { Color = fallback } } )
77 -end
79 -local fixed_badge = function ( elements, badge, color, fallback )
80 - table.insert( elements, { Text = ' ' } )
81 - table.insert( elements, { Foreground = { Color = color or fallback } } )
82 - table.insert( elements, { Text = badge or ' ' } )
83 - table.insert( elements, { Foreground = { Color = fallback } } )
84 -end
86 -local state_badge = function ( state )
87 - if state == 'busy' or state == 'running' or state == 'thinking' or state == 'loading' then return busy_badge() end
88 - if state == 'done' or state == 'success' then return '✓', palette.ui.important_local end
89 - if state == 'error' or state == 'failed' then return '✗', palette.error end
90 - if state == 'aborted' then return '×', palette.warning end
91 - if state == 'waiting' or state == 'input' or state == 'needs_input' then return '?', palette.warning end
92 - return nil
93 -end
95 -local user_state_badge = function ( vars )
96 - vars = vars or {}
97 - local badge, color = state_badge( vars.WEZTERM_STATE )
98 - if badge then return badge, color end
99 - return state_badge( vars.PI_STATE )
100 -end
102 -local ACTIVITY_MARKERS = {
103 - -- Codex/Pi/Claude terminal-title spinner frames. Never render these in labels.
104 - '◌', '○', '◐', '◓', '◑', '◒', '◎', '◉', '●',
105 - '◜', '◠', '◝', '◞', '◡', '◟',
106 - '⠁', '⠂', '⠄', '⠆', '⠇', '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠏', '⠐',
107 - '⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷',
108 - '✳', '✢', '✣', '✤', '✥', '✦', '✧', '✶', '✷', '✸', '✹', '✺', '✻', '✼', '✽', '✾', '✿',
111 -local strip_activity_marker = function ( title )
112 - title = apps.clean_title( title )
113 - if not title then return nil, false end
115 - local had_marker = false
116 - local changed = true
117 - while changed do
118 - changed = false
119 - title = apps.clean_title( title ) or title
120 - for _, marker in ipairs( ACTIVITY_MARKERS ) do
121 - if title:sub( 1, #marker ) == marker then
122 - title = title:sub( #marker + 1 )
123 - had_marker = true
124 - changed = true
125 - end
126 - if title:sub( -#marker ) == marker then
127 - title = title:sub( 1, #title - #marker )
128 - had_marker = true
129 - changed = true
130 - end
131 - end
132 - end
134 - return apps.clean_title( title ), had_marker
135 -end
137 -local activity_badge = function ( title )
138 - local _, had_marker = strip_activity_marker( title )
139 - if had_marker then return busy_badge() end
140 - return nil
141 -end
143 -local short_workspace = function ( name )
144 - local home = wez.home_dir
145 - if home and name:sub( 1, #home ) == home then
146 - name = '~' .. name:sub( #home + 1 )
147 - end
149 - -- Workspaces created from zoxide entries are often full paths.
150 - -- In the status bar, basename carries enough identity and avoids crowding tabs.
151 - if name:find( '/', 1, true ) or name:find( '\\', 1, true ) then
152 - return basename( name ) or name
153 - end
155 - if #name > 16 then
156 - return wez.truncate_right( name, 16 )
157 - end
158 - return name
159 -end
161 -local workspace_summaries = function ()
162 - local ok, mux_windows = pcall( wez.mux.all_windows )
163 - if not ok then return {} end
165 - local summaries = {}
166 - for _, mux_window in ipairs( mux_windows ) do
167 - local ok_workspace, workspace = pcall( function () return mux_window:get_workspace() end )
168 - if ok_workspace and workspace then
169 - local summary = summaries[workspace]
170 - if not summary then
171 - summary = { name = workspace, windows = 0, tabs = 0, panes = 0, badge = nil, badge_color = nil }
172 - summaries[workspace] = summary
173 - end
174 - summary.windows = summary.windows + 1
176 - local ok_tabs, tabs = pcall( function () return mux_window:tabs() end )
177 - if ok_tabs then
178 - for _, tab in ipairs( tabs ) do
179 - summary.tabs = summary.tabs + 1
180 - local ok_panes, panes = pcall( function () return tab:panes_with_info() end )
181 - if ok_panes then
182 - for _, info in ipairs( panes ) do
183 - summary.panes = summary.panes + 1
184 - local vars = safe_user_vars( info.pane )
185 - local badge, color = user_state_badge( vars )
186 - if badge and (not summary.badge or badge == '✗' or badge == '?') then
187 - summary.badge = badge
188 - summary.badge_color = color
189 - end
190 - end
191 - end
192 - end
193 - end
194 - end
195 - end
197 - return summaries
198 -end
200 -local workspace_hud = function ( active_workspace )
201 - local summaries = workspace_summaries()
202 - local names = {}
203 - for name in pairs( summaries ) do table.insert( names, name ) end
204 - table.sort( names )
206 - local ordered = {}
207 - if summaries[active_workspace] then table.insert( ordered, active_workspace ) end
208 - for _, name in ipairs( names ) do
209 - if name ~= active_workspace then table.insert( ordered, name ) end
210 - end
212 - local elements = {}
213 - local shown = 0
214 - for _, name in ipairs( ordered ) do
215 - shown = shown + 1
216 - if shown > 5 then break end
218 - local active = name == active_workspace
219 - local fg = active and palette.ui.important_local or palette.ui.minor
220 - local summary = summaries[name]
221 - table.insert( elements, { Foreground = { Color = fg } } )
222 - if active then table.insert( elements, { Attribute = { Intensity = 'Bold' } } ) end
223 - table.insert( elements, { Text = (active and ' ● ' or ' ○ ') .. short_workspace( summary.name ) } )
224 - if not active then
225 - colored_badge( elements, summary.badge, summary.badge_color, fg )
226 - end
227 - if active and summary.tabs > 1 then
228 - table.insert( elements, { Text = ' ' .. tostring( summary.tabs ) .. 't' } )
229 - end
230 - table.insert( elements, { Text = ' ' } )
231 - table.insert( elements, { Attribute = { Intensity = 'Normal' } } )
232 - end
234 - if #ordered > 5 then
235 - table.insert( elements, { Foreground = { Color = palette.ui.minor } } )
236 - table.insert( elements, { Text = ' +' .. tostring( #ordered - 5 ) .. ' ' } )
237 - end
239 - table.insert( elements, { Text = ' ' } )
241 - return elements
242 -end
244 -local nerd_icon = function ( fallback, ... )
245 - for _, name in ipairs { ... } do
246 - if wez.nerdfonts[name] then return wez.nerdfonts[name] end
247 - end
248 - return fallback
249 -end
251 71 local host_domain = function ()
252 72 local triple = wez.target_triple or ''
253 - if triple:find( 'windows', 1, true ) then
254 - return 'WIN', nerd_icon( '□', 'dev_windows', 'md_microsoft_windows', 'cod_terminal_powershell' ), palette.warning
255 - elseif triple:find( 'darwin', 1, true ) then
256 - return 'MAC', nerd_icon( '□', 'dev_apple', 'fa_apple' ), palette.ui.important_local
257 - elseif triple:find( 'linux', 1, true ) then
258 - return 'LIN', nerd_icon( '□', 'dev_linux', 'cod_terminal_linux' ), palette.ui.important_local
259 - elseif triple:find( 'bsd', 1, true ) then
260 - return 'BSD', nerd_icon( '□', 'dev_freebsd' ), palette.ui.important_local
261 - end
262 - return 'LOC', nerd_icon( '□', 'cod_terminal' ), palette.ui.important_local
73 + if triple:find( 'windows', 1, true ) then return 'WIN', wez.nerdfonts.dev_windows or '□', palette.warning end
74 + if triple:find( 'darwin', 1, true ) then return 'MAC', wez.nerdfonts.dev_apple or '□', palette.ui.important_local end
75 + if triple:find( 'linux', 1, true ) then return 'LIN', wez.nerdfonts.dev_linux or '□', palette.ui.important_local end
76 + if triple:find( 'bsd', 1, true ) then return 'BSD', wez.nerdfonts.dev_freebsd or '□', palette.ui.important_local end
77 + return 'LOC', wez.nerdfonts.cod_terminal or '□', palette.ui.important_local
265 -local domain_hud = function ( domain )
266 - local label, icon, color
268 - if not domain or domain == 'local' or domain == 'Local' then
269 - label, icon, color = host_domain()
270 - elseif domain:find( '^WSL:', 1, false ) then
271 - label = 'WSL'
272 - icon = nerd_icon( '□', 'dev_linux', 'cod_terminal_linux' )
273 - color = palette.ui.important_local
274 - elseif domain:find( '^scope:', 1, false ) then
275 - label = 'EXE'
276 - icon = nerd_icon( '□', 'cod_gear', 'md_cog' )
277 - color = palette.warning
278 - else
279 - label = ( domain:upper():gsub( '[^%w]', '' ):sub( 1, 3 ) .. 'LOC' ):sub( 1, 3 )
280 - icon = nerd_icon( '□', 'cod_terminal' )
281 - color = palette.ui.important_local
282 - end
284 - return {
285 - { Foreground = { Color = color } },
286 - { Attribute = { Intensity = 'Bold' } },
287 - { Text = icon .. ' ' .. label .. ' ' },
288 - { Attribute = { Intensity = 'Normal' } },
289 - }
290 -end
292 -local root_or_nil = function ( program )
293 - program = apps.normalize( program )
294 - if apps.is_root( program ) then return program end
295 - return nil
296 -end
298 -local tab_label = function ( program, detail )
299 - program = root_or_nil( program ) or FALLBACK_TAB_PROGRAM
300 - local base = apps.label( program ) or apps.label( FALLBACK_TAB_PROGRAM )
301 - return detail and (base .. ' · ' .. detail) or base
302 -end
304 -local title_program = function ( title )
305 - title = strip_activity_marker( title )
306 - if not title then return nil end
307 - if title:sub( 1, #'π' ) == 'π' then return 'pi' end
309 - -- Titles are prose while agents run. Trust only a leading app token; never
310 - -- classify from words inside task text like "Fix Claude settings".
311 - return root_or_nil( title:match( '^([%w%._%-]+)' ) )
312 -end
314 -local title_detail = function ( title, program, include_shell_titles )
315 - title = strip_activity_marker( title )
316 - if not title then return nil end
318 - local detail = apps.title_detail( title, program, include_shell_titles ) or title
319 - detail = strip_activity_marker( detail )
320 - detail = apps.clean_title( detail )
321 - if not detail or apps.normalize( detail ) == apps.normalize( program ) then return nil end
322 - return detail
323 -end
325 -local detect_from_process_info = function ( info )
326 - local detected = nil
327 - local visit
328 - visit = function ( node )
329 - if detected or type( node ) ~= 'table' then return end
331 - for _, key in ipairs { 'name', 'executable' } do
332 - detected = detected or root_or_nil( node[key] )
333 - end
334 - if type( node.argv ) == 'table' then
335 - for _, arg in ipairs( node.argv ) do
336 - detected = detected or root_or_nil( arg )
337 - end
338 - end
339 - if detected then return end
341 - if type( node.children ) == 'table' then
342 - for _, child in pairs( node.children ) do visit( child ) end
343 - end
344 - end
345 - visit( info )
346 - return detected
347 -end
349 -local process_info_program = function ( tab )
350 - local pane_id = tab.active_pane and tab.active_pane.pane_id
351 - if not pane_id then return nil end
353 - local ok_pane, mux_pane = pcall( wez.mux.get_pane, pane_id )
354 - if not ok_pane or not mux_pane then return nil end
356 - local ok_info, info = pcall( mux_pane.get_foreground_process_info, mux_pane )
357 - if not ok_info or not info then return nil end
359 - return detect_from_process_info( info )
360 -end
362 -local tab_title = function ( tab )
363 - local explicit_title = apps.clean_title( tab.tab_title )
364 - local pane_title = apps.clean_title( tab.active_pane.title )
365 - local display_title = explicit_title or pane_title
366 - local vars = tab.active_pane.user_vars or {}
368 - local detected = root_or_nil( apps.detect_from_commandline( vars.WEZTERM_PROG ) )
369 - or process_info_program( tab )
370 - or root_or_nil( tab.active_pane.foreground_process_name )
371 - or title_program( display_title )
372 - or FALLBACK_TAB_PROGRAM
374 - local detail = title_detail( display_title, detected, explicit_title ~= nil )
375 - return tab_label( detected, detail ), program_icon( detected ), detected
376 -end
378 -local tab_colors = function ( tab, hover )
379 - if tab.is_active then return palette.ui.focus, palette.content.backdrop end
380 - if hover then return palette.ui.accent, palette.content.backdrop end
381 - if tab.is_last_active then return palette.ui.backdrop, palette.ui.important_local end
382 - return palette.ui.backdrop, palette.content.normal
383 -end
385 -local tab_state_badge = function ( tab )
386 - local badge, color = user_state_badge( tab.active_pane.user_vars )
387 - if badge then return badge, color end
389 - local has_progress, progress = pcall( function () return tab.active_pane.progress end )
390 - badge, color = progress_badge( has_progress and progress or 0 )
391 - if badge then return badge, color end
393 - local id = tab.tab_id or tab.tab_index
394 - badge, color = activity_badge( tab.active_pane.title )
395 - if badge then
396 - tab_activity_until[id] = wall_seconds() + 2.0
397 - return badge, color
398 - end
400 - for _, pane_info in ipairs( tab.panes or {} ) do
401 - if pane_info.has_unseen_output then
402 - tab_activity_until[id] = wall_seconds() + 2.0
403 - return busy_badge()
404 - end
405 - end
406 - if tab_activity_until[id] and tab_activity_until[id] > wall_seconds() then
407 - return busy_badge()
408 - end
409 - tab_activity_until[id] = nil
410 - return nil
80 +local domain_label = function ( domain )
81 + if not domain or domain == 'local' or domain == 'Local' then return host_domain() end
82 + if domain:find( '^WSL:', 1, false ) then return 'WSL', wez.nerdfonts.dev_linux or '□', palette.ui.important_local end
83 + if domain:find( '^scope:', 1, false ) then return 'EXE', wez.nerdfonts.cod_gear or '□', palette.warning end
84 + return ( domain:upper():gsub( '[^%w]', '' ):sub( 1, 3 ) .. 'LOC' ):sub( 1, 3 ), wez.nerdfonts.cod_terminal or '□', palette.ui.important_local
413 87 wez.on( 'format-tab-title', function ( tab, tabs, panes, config, hover, max_width )
414 88 if config then use_palette_for_scheme( config.color_scheme ) end
415 - local title, icon = tab_title( tab )
416 - local state_badge, state_badge_color = tab_state_badge( tab )
417 - local bg, fg = tab_colors( tab, hover )
418 - local bar_bg = palette.content.backdrop
419 - local shadow = tab.is_active and palette.ui.accent or palette.content.backdrop
420 - local left_sep = wez.nerdfonts.ple_left_half_circle_thick or '\u{e0b4}'
421 - local right_sep = wez.nerdfonts.ple_right_half_circle_thick or '\u{e0b6}'
422 - local dot = tab.is_active and '●' or '○'
423 - local chrome_width = 8 -- separators, padding, fixed state-badge slot
424 - local budget = math.max( 1, max_width - chrome_width )
425 - local text = wez.truncate_right( string.format( ' %s %d %s %s', dot, tab.tab_index + 1, icon, title ), budget )
427 - local elements = {
428 - { Background = { Color = bar_bg } },
429 - { Foreground = { Color = shadow } },
430 - { Text = ' ' },
431 - { Foreground = { Color = bg } },
432 - { Text = left_sep },
90 + local bg = palette.content.backdrop
91 + local fg = palette.content.minor
92 + if tab.is_active then
93 + bg = palette.ui.focus
94 + fg = palette.content.backdrop
95 + elseif hover then
96 + bg = palette.ui.accent
97 + fg = palette.content.backdrop
98 + end
100 + local marker = tab.is_active and '●' or '○'
101 + local title = tab_text( tab )
102 + local label = string.format( ' %s %d %s ', marker, tab.tab_index + 1, title )
103 + label = wez.truncate_right( label, math.max( 1, max_width or 32 ) )
105 + return {
433 106 { Background = { Color = bg } },
434 107 { Foreground = { Color = fg } },
435 108 { Attribute = { Intensity = tab.is_active and 'Bold' or 'Normal' } },
436 - { Text = text },
109 + { Text = label },
110 + 'ResetAttributes',
438 - fixed_badge( elements, state_badge, state_badge_color, fg )
439 - table.insert( elements, { Text = ' ' } )
440 - table.insert( elements, { Background = { Color = bar_bg } } )
441 - table.insert( elements, { Foreground = { Color = bg } } )
442 - table.insert( elements, { Text = right_sep } )
443 - table.insert( elements, { Foreground = { Color = shadow } } )
444 - table.insert( elements, { Text = ' ' } )
445 - table.insert( elements, { Attribute = { Intensity = 'Normal' } } )
446 - return elements
449 -wez.on( 'format-window-title', function ( tab, pane, tabs, panes, config )
114 +wez.on( 'format-window-title', function ( tab )
450 115 local ok, workspace = pcall( wez.mux.get_active_workspace )
451 116 workspace = ok and workspace or 'default'
452 - local title = tab and tab_title( tab ) or 'WezTerm'
117 + local title = tab and tab_text( tab ) or 'WezTerm'
453 118 return '[' .. workspace .. '] ' .. title
456 --- Show which key table is active in the status area
457 121 wez.on( 'update-status', function ( window, pane )
458 122 local ok_status, status_error = pcall( function ()
459 - use_palette_for_window( window )
460 - local key_table = window:active_key_table()
461 - local current_workspace = window:active_workspace()
462 - local zoomed_state_ok, zoomed_state = pcall( zoomed, pane )
463 - zoomed_state = zoomed_state_ok and zoomed_state or nil
464 - local leader = nil
465 - if window:leader_is_active() then
466 - leader = '󱁐 '
467 - end
468 - local pane_domain_ok, pane_domain = pcall( pane.get_domain_name, pane )
469 - if not pane_domain_ok then return end
123 + use_palette_for_window( window )
471 - local status = {}
125 + local right = {}
126 + local key_table = window:active_key_table()
127 + if window:leader_is_active() then key_table = 'LEADER' end
128 + if key_table then
129 + right = {
130 + { Background = { Color = palette.error } },
131 + { Foreground = { Color = palette.ui.backdrop } },
132 + { Attribute = { Intensity = 'Bold' } },
133 + { Text = ' ' .. key_table .. ' ' },
134 + 'ResetAttributes',
135 + { Text = ' ' },
137 + end
473 - if zoomed_state then
474 - table.insert( status, zoomed_state )
475 - end
139 + local ok_zoom, zoomed_state = pcall( zoomed, pane )
140 + if ok_zoom and zoomed_state then
141 + table.insert( right, { Foreground = { Color = palette.ui.minor } } )
142 + table.insert( right, { Text = zoomed_state .. ' ' } )
143 + end
144 + window:set_right_status( wez.format( right ) )
477 - local status_parts = {}
478 - for _, value in ipairs( status ) do
479 - if value and value ~= '' then table.insert( status_parts, value ) end
480 - end
146 + local battery = bat.get_battery_icons()
147 + if battery ~= '' then battery = battery .. ' ' end
482 - local right_elements = {}
483 - if key_table or leader then
484 - local mode_text = key_table or 'LEADER'
485 - right_elements = {
486 - { Background = { Color = palette.error } },
487 - { Foreground = { Color = palette.ui.backdrop } },
149 + local ok_domain, domain = pcall( pane.get_domain_name, pane )
150 + local domain_text, domain_icon, domain_color = domain_label( ok_domain and domain or nil )
151 + local workspace = short_workspace( window:active_workspace() )
153 + window:set_left_status( wez.format {
154 + { Text = battery },
155 + { Foreground = { Color = palette.ui.important_local } },
488 156 { Attribute = { Intensity = 'Bold' } },
489 - { Text = ' 󱁐 ' .. mode_text .. ' ' },
157 + { Text = '● ' .. workspace .. ' ' },
158 + { Foreground = { Color = domain_color } },
159 + { Text = domain_icon .. ' ' .. domain_text .. ' ' },
490 160 'ResetAttributes',
491 - { Text = ' ' },
492 - }
493 - end
495 - local status_text = table.concat( status_parts, DELIMITER )
496 - if status_text ~= '' then
497 - table.insert( right_elements, { Foreground = { Color = palette.ui.minor } } )
498 - table.insert( right_elements, { Text = status_text .. ' ' } )
499 - end
501 - window:set_right_status( wez.format( right_elements ) )
502 - local battery_icons = bat.get_battery_icons()
503 - if battery_icons ~= '' then
504 - battery_icons = battery_icons .. ' '
505 - end
507 - local left_elements = {
508 - { Text = battery_icons },
509 - }
510 - for _, element in ipairs( workspace_hud( current_workspace ) ) do
511 - table.insert( left_elements, element )
512 - end
513 - for _, element in ipairs( domain_hud( pane_domain ) ) do
514 - table.insert( left_elements, element )
515 - end
517 - window:set_left_status( wez.format( left_elements ) )
161 + } )
520 164 if not ok_status then
529 173 return function ( cfg )
530 174 cfg.enable_tab_bar = true
531 - -- if this is hidden, we cannot see the right status are
532 175 cfg.hide_tab_bar_if_only_one_tab = false
533 176 cfg.use_fancy_tab_bar = false
534 - cfg.tab_max_width = 172
177 + cfg.tab_max_width = 64
535 178 cfg.show_tabs_in_tab_bar = true
536 179 cfg.show_new_tab_button_in_tab_bar = false
537 180 cfg.tab_bar_at_bottom = true