-
Hi! I made a little bash script that prints the current working directory in a nice format. When I execute this script in a pane it correctly outputs the current working directory of that pane. However, in the statusbar the contents of the widget never change. I'm assuming that the command is run in the context of the Zellij pane that holds the zjstatus status bar. Therefore it doesn't "update" like I would expect... Since the current working dir of the statusbar pane never updates... Did anyone figure out how to accomplish this? Thanks! The script: #!/bin/bash
if git rev-parse --is-inside-work-tree &>/dev/null; then
git_root=$(git rev-parse --show-toplevel)
git_relative_path=$(git rev-parse --show-prefix | sed 's#/$##')
if [ "$git_relative_path" = '' ]; then
echo "$(basename "$git_root")"
else
echo "$(basename "$git_root")/$git_relative_path"
fi
else
if [[ "$PWD" == "$HOME"* ]]; then
echo "~${PWD#$HOME}"
else
echo "$PWD"
fi
fi How I run it:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Hey @sommerper! Sorry to just mention you like this.... but I noticed in #22 that you played around with some |
Beta Was this translation helpful? Give feedback.
-
Thinking of this some more... all I was really hoping I could get a display similar to my prompt into the status bar so I have al that same info when inside fullscreen TUIs like NeoVim and LazyGit etc. Because this looks really cool right!? The one idea I currently have is to hook into Zellij / ZSH and just send all of the metadata to a file or something so the statusbar commands can read from there.. Similar to this setup for changing tab titles but slightly different & probably slightly more robuust. (I don't think that solution can handle multiple panes in a single tab correctly. You'd need trigger something in zsh in the pane for it to pick up changes..) (A quick search landed me on another one of your plugins: zj-hooks. Cool!) I'm afraid this will get pretty gnarly having to handle multiple sessions etc. I'm not sure yet. Really all I need is info on the Perhaps more zj-status users want the same type of functionality? It might make sense to see if there is a way to get |
Beta Was this translation helpful? Give feedback.
-
Hi and thanks a lot for sharing all of your thoughts and ideas! I really appreciate your effort. First of all, I want to elaborate a bit how the plugins work. Plugins are small wasm files, that are loaded into their own pane, which results them in running in a sandbox. E.g. they can only access certain APIs and paths, that are granted by the user (or implicitely by zellij). That means, that wasm plugins only have access to the information received from zellij besides the directory they are started in. When executing a command (within the command widget), the wasm plugin tells zellij to run the command. So it's neither directly executed by the plugin nor within a shell environment. In some of the last releases, I've implemented a feature to tell zellij the CWD a command is executed in. We could utilize this one in the future to implement the dynamic CWD. However, there are some challenges. E.g. there can be multiple panes within a tab with different CWDs set. Which one should be used for the commands? One could assume, that it'll always run in the focused pane, but this can also result in errors or other weird behavior, when e.g. the pane contains an elevated shell and the zellij user does not have permissions in this directory. Another challenge right now is, that the plugins are not capable of retrieving the CWD from panes within the sessions. Thus we need to first wait for an implementation on zellijs side. There's also some issue for this open (which does not really reflect the feature by it's title :D but the title implicates it). Here's the link to the comment: #92 (comment) I hope this explained the current situation a bit and revealed some insights why it currently is not available. As soon as we are capable of getting the CWD, I'd happily use your suggestion of the magic Happy hacking! Edit your screenshot looks awesome and clean! |
Beta Was this translation helpful? Give feedback.
Hi and thanks a lot for sharing all of your thoughts and ideas! I really appreciate your effort.
First of all, I want to elaborate a bit how the plugins work. Plugins are small wasm files, that are loaded into their own pane, which results them in running in a sandbox. E.g. they can only access certain APIs and paths, that are granted by the user (or implicitely by zellij). That means, that wasm plugins only have access to the information received from zellij besides the directory they are started in.
When executing a command (within the command widget), the wasm plugin tells zellij to run the command. So it's neither directly executed by the plugin nor within a shell environment. In some…