repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

wezterm: better status for wsl and host

d58130fa17f2962690c9f7e49fa3c58b5964adb2

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

unsigned

Browse filesCompare with HEAD

Changed files (1)

wezterm/bugabinga/status.lua

Modified
261 261 return elements
264 +local 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
269 +end
271 +local 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
283 +end
264 285 local domain_hud = function ( domain )
265 - local label = domain or 'local'
266 - local color = palette.ui.important_local
286 + local label, icon, color
268 288 if not domain or domain == 'local' or domain == 'Local' then
269 - label = 'WIN'
270 - color = palette.warning
289 + label, icon, color = host_domain()
271 290 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
273 294 elseif domain:find( '^scope:', 1, false ) then
295 + label = 'EXE'
296 + icon = nerd_icon( '□', 'cod_gear', 'md_cog' )
274 297 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
277 304 return {
278 305 { Foreground = { Color = color } },
279 306 { Attribute = { Intensity = 'Bold' } },
280 - { Text = '@' .. label .. ' ' },
307 + { Text = icon .. ' ' .. label .. ' ' },
281 308 { Attribute = { Intensity = 'Normal' } },
478 505 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 = ' ' },
516 + end
479 518 local status_text = table.concat( status_parts, DELIMITER )
480 519 if status_text ~= '' then
481 520 table.insert( right_elements, { Foreground = { Color = palette.ui.minor } } )
488 527 battery_icons = battery_icons .. ' '
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 },
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 )
514 540 window:set_left_status( wez.format( left_elements ) )