Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipe command to rerun {command_git_branch} not working #92

Open
axburgess-godaddy opened this issue Nov 5, 2024 · 4 comments
Open

Pipe command to rerun {command_git_branch} not working #92

axburgess-godaddy opened this issue Nov 5, 2024 · 4 comments
Labels
blocked enhancement New feature or request

Comments

@axburgess-godaddy
Copy link

Describe the bug
zellij pipe "zjstatus::rerun::command_git_branch" doesn't appear to work as expected.

To Reproduce

  1. open a new session in a git repo; note branch name is shown
  2. change directories
  3. run zellij pipe "zjstatus::rerun::command_git_branch"
  4. branch name is not updated

Expected behavior
pipe command should rerun the branch command and update the displayed branch name

Desktop (please complete the following information):

  • OS: macos
  • Zellij version 0.41.1
  • Version Release v0.18.1

Layout

How does the layout look like? Please copy it into a code block.

  default_tab_template {
    children
    pane size=1 borderless=true {
      plugin location="file:~/.config/zellij/plugins/zjstatus.wasm" {
        format_left   "{mode} #[fg=#6C7086]{session} {tabs}"
        format_right  "#[fg=#FF00D9]{command_git_branch} #[fg=#6C7086]{datetime} {swap_layout}"

        mode_locked "#[bg=#FF00D9,bold] "
        mode_normal "#[bg=#008EC4,bold] "
        mode_tmux "#[bg=#ff6e27,bold] "
        mode_resize "#[bg=#ff6e27,bold] #[bg=#1D1F21,fg=#ff6e27] {name}"
        mode_default_to_mode "resize"

        tab_normal "#[bg=#8A8A8A,fg=#1D1F21] #[bg=#8A8A8A,fg=#e0e0e0]{name} {sync_indicator}{fullscreen_indicator}{floating_indicator} #[bg=#1D1F21,fg=#8A8A8A]"
        tab_active "#[bg=#008EC4,fg=#1D1F21] #[bg=#008EC4,fg=#35373B]{name} {sync_indicator}{fullscreen_indicator}{floating_indicator} #[bg=#1D1F21,fg=#008EC4]"

        format_space  ""

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

        hide_frame_for_single_pane "false"

        command_git_branch_command     "git rev-parse --abbrev-ref HEAD"
        command_git_branch_format      "#[fg=#FF00D9] {stdout}"
        command_git_branch_interval    "5"
        command_git_branch_rendermode  "dynamic"

        datetime        "#[fg=#6C7086] {format} "
        datetime_format "%A, %d %b %Y %H:%M"
        datetime_timezone "US/Pacific"


        tab_sync_indicator       " "
        tab_fullscreen_indicator "□ "
        tab_floating_indicator   "󰉈 "
      }
    }
  }

Additional context
Add any other context about the problem here.

I'm trying to use add-zsh-hook -Uz chpwd (){ zellij pipe "zjstatus::rerun::command_git_branch"; } to update the branch name when I change directories, but it seems to not work to rerun the command manually either.

Thanks for investigating!

@axburgess-godaddy axburgess-godaddy added the bug Something isn't working label Nov 5, 2024
@dj95
Copy link
Owner

dj95 commented Nov 5, 2024

Hi!

Thank you for the detailed bug report.

Unfortunately, I cannot really do much about this issue. Zellij is executing the plugin commands within the directory, in which the zellij session was started. Thus we cannot change directory for the running command, even on a refresh.

Let me check in the next days, if there's a way to extract the CWD of the currently focused pane. If so, we could add a switch for command widgets to follow the focus with the CWD.

@axburgess-godaddy
Copy link
Author

That would be perfect, Thanks!

@dj95 dj95 added enhancement New feature or request blocked and removed bug Something isn't working labels Nov 6, 2024
@dj95
Copy link
Owner

dj95 commented Nov 6, 2024

I've took a look at the documentation. We're able to get the focused pane, but not the cwd :/ therefore I cannot implement this behavior.

As the current behavior is the default one of zellij, I would not consider it a bug, but more as a feature request. I hope this is fine for you.

I'll ask on the zellij side, if we can add some APIs, such that these things will be possible. But I'm not sure, if it's feasible, as retrieving the CWD could differ from the shell and command that's running in the pane.


Ref: https://docs.rs/zellij-tile/latest/zellij_tile/prelude/struct.PaneInfo.html

@dj95
Copy link
Owner

dj95 commented Nov 6, 2024

Update: the CWD will be added to the PaneInfo in the future. Thus I'd like to stall this issue until we got the field to implement it in a clean way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants