dotfiles
bugabingas dorkfiles
owned by bugabinga
wezterm: better status for wsl and host
c53d45c79a88db0e83169e76d260f2dbf028e4be
Oliver Krylow <o.krylow@isp-insoft.de> ·
unsigned
Browse filesCompare with HEAD
Changed files (1)
wezterm/bugabinga/status.lua
Modified 264 +local nerd_icon = function ( fallback,
... )
265 + for _, name
in ipairs {
... }
do 266 + if wez.nerdfonts[name]
then return wez.nerdfonts[name]
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
282 + return 'LOC', nerd_icon(
'□',
'cod_terminal' ), palette.ui.important_local
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 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 ' )
292 + icon
= nerd_icon(
'□',
'dev_linux',
'cod_terminal_linux' )
293 + color
= palette.ui.important_local
273 294 elseif domain:find(
'^scope:',
1,
false )
then 296 + icon
= nerd_icon(
'□',
'cod_gear',
'md_cog' )
274 297 color
= palette.warning
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
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' 509 + {
Background = {
Color = palette.error } },
510 + {
Foreground = {
Color = palette.ui.backdrop } },
511 + {
Attribute = {
Intensity =
'Bold' } },
512 + {
Text =
' ' .. mode_text
.. ' ' },
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' 495 - {
Background = {
Color = palette.error } },
496 - {
Foreground = {
Color = palette.ui.backdrop } },
497 - {
Attribute = {
Intensity =
'Bold' } },
498 - {
Text =
' ' .. mode_text
.. ' ' },
504 - {
Text = battery_icons },
506 - for _, element
in ipairs( workspace_hud( current_workspace ) )
do 507 - table.
insert( left_elements, element )
509 - for _, element
in ipairs( domain_hud( pane_domain ) )
do 510 - table.
insert( left_elements, element )
530 + local left_elements
= {
531 + {
Text = battery_icons },
533 + for _, element
in ipairs( workspace_hud( current_workspace ) )
do 534 + table.
insert( left_elements, element )
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 ) )