dj95 / zjstatus

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

can't show output of custom comman_NAME_command #62

Closed nbari closed 1 month ago

nbari commented 1 month ago

Hi, first of all thanks for your time creating and sharing this plugin, I don't know if this is a bug or problem with my configuration, I am trying run this command:

uptime | grep -o '..user.*'

So that it looks similar to this tmux: https://i.imgur.com/ag3cv0C.png

This is my layouts/default.kdl

layout {
    default_tab_template {
        pane size=1 borderless=true {
            plugin location="https://github.com/dj95/zjstatus/releases/latest/download/zjstatus.wasm" {
                format_left   "{mode} #[fg=#89B4FA,bold]{session}"
                format_center "{tabs}"
                format_right  "{command_git_branch} {datetime}"
                format_space  ""

                border_enabled  "false"
                border_char     "─"
                border_format   "#[fg=#6C7086]{char}"
                border_position "top"

                hide_frame_for_single_pane "false"

                mode_normal  "#[bg=blue] "
                mode_tmux    "#[bg=#ffc387] "

                tab_normal   "#[fg=#6C7086] {name} "
                tab_active   "#[fg=#9399B2,bold,italic] {name} "

                command_git_branch_command     "bash -c \"uptime | grep -o '..user.*'\""
                command_git_branch_format      "#[fg=blue] {stdout}"
                command_git_branch_interval    "30"
                command_git_branch_rendermode  "raw"

                datetime        "#[fg=#6C7086,bold] {format} "
                datetime_format "%H:%M:%S"
                datetime_timezone "Europe/Berlin"
            }
        }
        children
    }
}

The version of zellij that I am using is zellig 0.40.1.

If for the command I use somethiing like command_uptime_command nothinig happens, I need to use command_git_branch_command here the command runs but I only see the seconds from the datetime.

Any idea if this is posisble? also I would like to have the status bar on top, that's why I ahve children at the bottom but in any case I still have the problem.

I tried to run zellig with the -d/--debug or RUST_LOG=debug zellij, and also printing {stderr} but can't find any logs therefore wondering how could I debug?

Any hint/tip would be apreciated.

dj95 commented 1 month ago

Hi and thanks for the detailed questions. I'm not really sure what the exact problem is.

At least on my machine the layout seem to work.

Screenshot 2024-05-26 at 20 10 31

If you want to rename the command_git_branch to command_uptime you can do it if you replace it everywhere it is used in the layout. Also in the format sections.

Here's an example

layout {
    default_tab_template {
        pane size=1 borderless=true {
            plugin location="https://github.com/dj95/zjstatus/releases/latest/download/zjstatus.wasm" {
                format_left   "{mode} #[fg=#89B4FA,bold]{session}"
                format_center "{tabs}"
-                format_right  "{command_git_branch} {datetime}"
+                format_right  "{command_uptime} {datetime}"
                format_space  ""

                border_enabled  "false"
                border_char     "─"
                border_format   "#[fg=#6C7086]{char}"
                border_position "top"

                hide_frame_for_single_pane "false"

                mode_normal  "#[bg=blue] "
                mode_tmux    "#[bg=#ffc387] "

                tab_normal   "#[fg=#6C7086] {name} "
                tab_active   "#[fg=#9399B2,bold,italic] {name} "

-                command_git_branch_command     "bash -c \"uptime | grep -o '..user.*'\""
-                command_git_branch_format      "#[fg=blue] {stdout}"
-                command_git_branch_interval    "30"
-                command_git_branch_rendermode  "raw"

+                command_uptime_command     "bash -c \"uptime | grep -o '..user.*'\""
+                command_uptime_format      "#[fg=blue] {stdout}"
+                command_uptime_interval    "30"
+                command_uptime_rendermode  "raw"

                datetime        "#[fg=#6C7086,bold] {format} "
                datetime_format "%H:%M:%S"
                datetime_timezone "Europe/Berlin"
            }
        }
        children
    }
}
nbari commented 1 month ago

Hi @dj95, many thanks for testing indeed that's the desired output, I tested in full screen and it works but when resizing the terminal it gets truncated, this is an example of how it looks (left side tmux, right side zellij + zjstatus):

image

Is it possible to skip the center and let panel/tabs at the left and custom options at the right?

dj95 commented 1 month ago

Sure, just play around with the format_left, format_center and format_right configuration. You can also leave them empty in case you don't need them. For further details, also take a look at the wiki: https://github.com/dj95/zjstatus/wiki/3-%E2%80%90-Configuration

nbari commented 1 month ago

This did it:

 format_left   "{mode} #[fg=#89B4FA,bold]{session}{tabs}"
 format_right  "{command_uptime} {datetime}"
 format_space  ""

Many thanks :+1: