dj95 / zjstatus

A configurable statusbar plugin for zellij
MIT License
358 stars 6 forks source link

Allow formatting using command output #25

Closed williampayne23 closed 6 months ago

williampayne23 commented 7 months ago

Is your feature request related to a problem? Please describe. I'd like to be able to run a command which outputs formatting commands like #[fg=#FFFFFF] and have them be evaluated properly The current behaviour is escaping the command output completely (see example). My use case is getting vim-tpipeline working with Zellij. Another use case might be color formatting based on git status.

Describe the solution you'd like I think by default command output should be evaluated before parsing the formatting

Additional context Here is an example of current behaviour:

.config/zellij/layout/default.kdl
...
            format_left  "{mode} #[fg=#89B4FA,bold]{session} {tabs}"
            format_right "{command_test}" 
            format_space ""
            command_test_command   "echo blue#[fg=red]red"
            command_test_format    "#[fg=blue] {stdout} "
            command_test_interval  "10"
...

What happens at the moment

image

What I'd expect

image
dj95 commented 7 months ago

Hey and thank you for the feature request.

I did not implement this feature because of performance reasons. The whole format and config parsing is done only on plugin start in order to minimise latency for rendering.

However, I'm also seeing the use-case, but I'm not sure if it will be a good idea to implement it - not only from the performance side, but also from the maintainability one. When zjstatus parses formats from the results, it might cause problems in certain edge cases, which I am not able to support (since I am the only maintainer unfortunately).

It might be better to consider writing another widget tailored to vim-tpipeline. This way you can also support the functionality in a better and more optimised way (even if it will parse the formats). But in this way only tpipeline will be affected and not the command widget, that might be heavily used by others. In this way it won't confuse on edge cases in the command widget as well, since the command widget will just further output the command result.

I'd be happy for a contribution since I'm not familiar with tpipeline and have only limited time.