repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

wezterm: show workspace chips

aab85db39f058368a388f3f6d9836d5b93a7e7a0

Oliver Krylow <o.krylow@isp-insoft.de> ·

unsigned

Browse filesCompare with HEAD

Show all known workspaces in the left status line.

Render the active workspace as a bracketed full name and inactive workspaces as short slugs. Make the default workspace picker switch in the current window.

Changed files (2)

+32 / −5 text lines

Diff layout

wezterm/bugabinga/key_binds.lua

Modified

+2 / −2 text lines

212212 {
213213 key = 'z',
214214 mods = 'LEADER',
215 action = workspace_switcher.switch_workspace_in_new_window(),
215 action = workspace_switcher.switch_workspace(),
216216 },
217217 {
218218 key = 'Z',
219219 mods = 'LEADER|SHIFT',
220 action = workspace_switcher.switch_workspace(),
220 action = workspace_switcher.switch_workspace_in_new_window(),
221221 },
222222 {
223223 key = 'k',

wezterm/bugabinga/status.lua

Modified

+30 / −3 text lines

2727 if ok and config then use_palette_for_scheme( config.color_scheme ) end
2828end
30local short_workspace = function ( name )
30local short_workspace = function ( name, max_width )
3131 name = clean( name ) or 'default'
3232 local home = wez.home_dir
3333 if home and name:sub( 1, #home ) == home then
3636 if name:find( '/', 1, true ) or name:find( '\\', 1, true ) then
3737 name = basename( name ) or name
3838 end
39 return wez.truncate_right( name, 18 )
39 return wez.truncate_right( name, max_width or 18 )
40end
42local workspace_slug = function ( name )
43 local slug = short_workspace( name ):gsub( '[^%w]', '' ):sub( 1, 3 ):lower()
44 return slug ~= '' and slug or '?'
45end
47local workspace_chips = function ( active )
48 active = clean( active ) or 'default'
50 local ok, names = pcall( wez.mux.get_workspace_names )
51 if not ok or type( names ) ~= 'table' or #names <= 1 then
52 return short_workspace( active )
53 end
55 table.sort( names, function ( a, b )
56 return tostring( a ):lower() < tostring( b ):lower()
57 end )
59 local parts = {}
60 for _, name in ipairs( names ) do
61 local label = workspace_slug( name )
62 if name == active then label = '[' .. short_workspace( name, 42 ) .. ']' end
63 table.insert( parts, label )
64 end
66 return table.concat( parts, ' ' )
4067end
4269local primary_pane = function ( tab )
149176 local ok_domain, domain = pcall( pane.get_domain_name, pane )
150177 local domain_text, domain_icon, domain_color = domain_label( ok_domain and domain or nil )
151 local workspace = short_workspace( window:active_workspace() )
178 local workspace = workspace_chips( window:active_workspace() )
153180 window:set_left_status( wez.format {
154181 { Text = battery },