repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

wezterm: better status for wsl and host

67ed529c3380c894164883106ded6ec078fc36d8

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

unsigned

Browse filesCompare with HEAD

Changed files (1)

+53 / −27 text lines

Diff layout

wezterm/bugabinga/status.lua

Modified

+53 / −27 text lines

261261 return elements
262262end
264local nerd_icon = function ( fallback, ... )
265 for _, name in ipairs { ... } do
266 if wez.nerdfonts[name] then return wez.nerdfonts[name] end
267 end
268 return fallback
269end
271local host_domain = function ()
272 local triple = wez.target_triple or ''
273 if triple:find( 'windows', 1, true ) then
274 return 'WIN', nerd_icon( '□', 'dev_windows', 'md_microsoft_windows', 'cod_terminal_powershell' ), palette.warning
275 elseif triple:find( 'darwin', 1, true ) then
276 return 'MAC', nerd_icon( '□', 'dev_apple', 'fa_apple' ), palette.ui.important_local
277 elseif triple:find( 'linux', 1, true ) then
278 return 'LIN', nerd_icon( '□', 'dev_linux', 'cod_terminal_linux' ), palette.ui.important_local
279 elseif triple:find( 'bsd', 1, true ) then
280 return 'BSD', nerd_icon( '□', 'dev_freebsd' ), palette.ui.important_local
281 end
282 return 'LOC', nerd_icon( '□', 'cod_terminal' ), palette.ui.important_local
283end
264285local domain_hud = function ( domain )
265 local label = domain or 'local'
266 local color = palette.ui.important_local
286 local label, icon, color
268288 if not domain or domain == 'local' or domain == 'Local' then
269 label = 'WIN'
270 color = palette.warning
289 label, icon, color = host_domain()
271290 elseif domain:find( '^WSL:', 1, false ) then
272 label = domain:gsub( '^WSL:', 'WSL ' )
291 label = 'WSL'
292 icon = nerd_icon( '□', 'dev_linux', 'cod_terminal_linux' )
293 color = palette.ui.important_local
273294 elseif domain:find( '^scope:', 1, false ) then
295 label = 'EXE'
296 icon = nerd_icon( '□', 'cod_gear', 'md_cog' )
274297 color = palette.warning
298 else
299 label = ( domain:upper():gsub( '[^%w]', '' ):sub( 1, 3 ) .. 'LOC' ):sub( 1, 3 )
300 icon = nerd_icon( '□', 'cod_terminal' )
301 color = palette.ui.important_local
275302 end
277304 return {
278305 { Foreground = { Color = color } },
279306 { Attribute = { Intensity = 'Bold' } },
280 { Text = '@' .. label .. ' ' },
307 { Text = icon .. ' ' .. label .. ' ' },
281308 { Attribute = { Intensity = 'Normal' } },
282309 }
283310end
476503 end
478505 local right_elements = {}
506 if key_table or leader then
507 local mode_text = key_table or 'LEADER'
508 right_elements = {
509 { Background = { Color = palette.error } },
510 { Foreground = { Color = palette.ui.backdrop } },
511 { Attribute = { Intensity = 'Bold' } },
512 { Text = ' 󱁐 ' .. mode_text .. ' ' },
513 'ResetAttributes',
514 { Text = ' ' },
515 }
516 end
479518 local status_text = table.concat( status_parts, DELIMITER )
480519 if status_text ~= '' then
481520 table.insert( right_elements, { Foreground = { Color = palette.ui.minor } } )
488527 battery_icons = battery_icons .. ' '
489528 end
491 local left_elements = {}
492 if key_table or leader then
493 local mode_text = key_table or 'LEADER'
494 left_elements = {
495 { Background = { Color = palette.error } },
496 { Foreground = { Color = palette.ui.backdrop } },
497 { Attribute = { Intensity = 'Bold' } },
498 { Text = ' 󱁐 ' .. mode_text .. ' ' },
499 'ResetAttributes',
500 { Text = ' ' },
501 }
502 else
503 left_elements = {
504 { Text = battery_icons },
505 }
506 for _, element in ipairs( workspace_hud( current_workspace ) ) do
507 table.insert( left_elements, element )
508 end
509 for _, element in ipairs( domain_hud( pane_domain ) ) do
510 table.insert( left_elements, element )
511 end
530 local left_elements = {
531 { Text = battery_icons },
532 }
533 for _, element in ipairs( workspace_hud( current_workspace ) ) do
534 table.insert( left_elements, element )
535 end
536 for _, element in ipairs( domain_hud( pane_domain ) ) do
537 table.insert( left_elements, element )
512538 end
514540 window:set_left_status( wez.format( left_elements ) )