-
-
Notifications
You must be signed in to change notification settings - Fork 679
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
Allow zellij run CLI command to block until command has completed #3018
Comments
+1. I need this feature to send text to the repl from Helix. See here how it's done for tmux. The idea is to focu on a pane, send text, send the enter key, and focus back on Helix |
I have this working with Yazi and Helix specifically: # config.toml
[keys.normal."'"]
y = ":sh zellij run --floating -n 'yazi picker' -- /home/rboynton/.config/fish/scripts/open_in_helix_from_yazi.fish" # open_in_helix_from_yazi.fish
set -l tmpfile /tmp/yazi-choice.txt
rm -f $tmpfile
yazi --chooser-file=$tmpfile
zellij action toggle-floating-panes
zellij action write 27 # send escape-key
zellij action write-chars ":open $(cat /tmp/yazi-choice.txt)"
zellij action write 13 # send enter-key
zellij action toggle-floating-panes
zellij action close-pane |
Cool, thank you for sharing it! @rockboynton Would you like to submit a PR and add it to the Tips page of the Yazi document? This way more people can see it. Edit: Added to https://yazi-rs.github.io/docs/tips/#helix-with-zellij, fell free to use it ;) example.mp4BTW I saw this comment from https://www.reddit.com/r/HelixEditor/comments/1chvan1/how_are_people_using_their_cli_file_explorers, hope I'm not too late here ;) |
In the meantime, one workaround to achieve blocking calls to set id (uuidgen)
mkfifo /tmp/$id
zellij run -fc -- fish -c "fzf | tee /tmp/$id"
cat < /tmp/$id > /dev/null
rm -rf /tmp/$id This will run Or, even shorter with process signals: zellij run -fc -- fish -c "fzf; kill -s CONT $fish_pid"
kill -s STOP $fish_pid |
Hopefully this isn't hijacking but I'd like to propose that if this kind of enhancement is deemed worthwhile, to allow options for both |
|
Thanks @rockboynton and @postsolar! Here's (single file) using zsh: # open_in_helix_from_yazi.zsh
file=$(yazi --chooser-file=/dev/stdout | cat)
zellij action toggle-floating-panes
zellij action write 27 # send escape-key
zellij action write-chars ":open $(command printf '%q' "$file")"
zellij action write 13 # send enter-key
zellij action toggle-floating-panes
zellij action close-pane |
@blixenkrone you can open multiple files at once if you change it to files=(${(fqq)"$( yazi --chooser-file=/dev/stdout | cat )"})
zellij action toggle-floating-panes
zellij action write 27 # send escape-key
zellij action write-chars ":open $files"
zellij action write 13 # send enter-key
zellij action toggle-floating-panes
zellij action close-pane This handles their quoting too. |
With this version i get the error "wrong argument count". |
You're probably executing the script with bash, not zsh, perhaps due to not adding the shebang? Try adding |
@postsolar |
Thanks for suggesting this feature. A few things:
While I totally empathize with people wanting this to be part of core, the philosophy of this project is to offload as much as possible to plugins in order to help us maintainers keep up. If someone makes a generic plugin that blocks until a command is done, I'd be happy to link to it and refer to it when this comes up. ADDENDUM: if someone is interested in implementing this plugin and wants support, they are welcome to join our Discord - there are lots of plugin authors there who'd be happy to help. |
The bash script assumes that the escape key puts the mode back to normal. # ~/.config/helix/config.toml
[keys.normal]
C-y = [
"normal_mode",
":sh zellij run -f -- bash ~/picker.sh"
] and do not write the escape key in the sh script. |
The
zellij run
command should have the ability to block until the command being run has exited.This would allow zellij to be invoked in scripts or shortcuts to perform actions and then have control returned to the caller.
For example, my use case is using Helix keybinds to invoke the Yazi file browser to select a file to which will then be opened in Helix. However currently I am unable to block until I've selected a file as the zellij command immediately exits.
The text was updated successfully, but these errors were encountered: