michaelbrusegard / tabline.wez

A versatile and easy to use retro tab bar plugin for the WezTerm terminal emulator created with the lualine.nvim configuration format
MIT License
55 stars 5 forks source link

add built in process icons and icons only option #14

Closed michaelbrusegard closed 1 month ago

michaelbrusegard commented 1 month ago

@joncrangle what do you think of having this builtin? You would only have to put the icons_only=true option on the process to make it behave the same way as your config does now. This works similarly to how the datetime and battery components do

joncrangle commented 1 month ago

I really like it. I didn't do a PR initially because the list of processes is endless, and it adds a maintenance task for you to deal with PRs to add additional processes. Since the user can provide their own process_to_icon table, they can add processes or customize icons, but you can weigh whether you're fine with the maintenance of additional PRs.

One thing I noticed in this PR is that it requires the process name be an exact match, so it won't always display the icon. I used the following in my config to make the lookup a bit looser and find the value if the lowercase process name starts with the key. This was in case the process name is uppercase (e.g. Topgrade) and also to capture the various domains which won't be an exact match (e.g. I wanted SSHMUX:my-domain to match the 'ssh' process icon).

local function get_icon(str)
  for k, v in pairs(icons) do
    if str:lower():match("^" .. k) then
      return v
    end
  end
  return icons['default']
end
michaelbrusegard commented 1 month ago

I forgot that, thanks for the response. I think it is alright to have in the library. That way the process to icon table can become more complete since more people are able to contribute.

I also am adding colors so the items in the icon mapping tables work like the other icon objects in the plugin. This can easily be overwritten by setting the icon color of the icon property in the component opts so if you don't per icon colors you can set a single color for every icon

michaelbrusegard commented 1 month ago

@joncrangle if you want it would be nice if you add colors to some of the other icons. I don't know the colors for all of them

joncrangle commented 1 month ago

@joncrangle if you want it would be nice if you add colors to some of the other icons. I don't know the colors for all of them

Yes - I'll go through and approximate ansi/brights with brand colors. I've also got an implementation for an opt to disable icon colors that I'll submit through the PR, in case users don't want colorful icons.