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

Add :pipe-to typable command that ignores shell output #4931

Merged
merged 3 commits into from
Dec 12, 2022

Conversation

alxshine
Copy link
Contributor

I often use an editor in conjunction with a REPL open in another terminal.
To quickly send commands from my editor to the REPL I pipe the editor selection into kitty's remote control feature: kitty @ send-text --match recent:1 --stdin.

In kakoune I could set up a keybinding utilizing the pipe-to command <Alt-|> and pass the shell command directly.
For helix I can only pass the command to typed arguments, but there is currently no typed command to pipe selections to shell commands while ignoring the output.

My suggestion is this:
Add a :pipe-to command which is essentially a copy of the :pipe command, but uses ShellBehavior::Ignore instead of the hard-coded ShellBehavior::Replace.

@kirawi kirawi added A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer. labels Nov 29, 2022
@QiBaobin
Copy link
Contributor

QiBaobin commented Nov 30, 2022

Is this better to implement in async approach as we don't need the result?

@alxshine
Copy link
Contributor Author

I can't reply for some reason, so here's my response:

I tried to keep it close to how the shell_pipe_to static command works.
All variants currently internally use the shell function to handle the subshell for the command.
The only outlier is the run_shell_command, which calls shell_impl directly.

If you want the new command to be async, then IMO so should the shell_pipe_to static command.
I don't know if it would be better to add an argument to the shell function, or add a separate shell_async function.
There is an underlying shell_impl_async function, which is currently only used wrapped in a tokio barrier, so a change would not be too complex.

If we wanted we could enable async shell commands, but I'm not sure if thats good default behavior.

@QiBaobin
Copy link
Contributor

QiBaobin commented Nov 30, 2022

I can't reply for some reason, so here's my response:

I tried to keep it close to how the shell_pipe_to static command works. All variants currently internally use the shell function to handle the subshell for the command. The only outlier is the run_shell_command, which calls shell_impl directly.

If you want the new command to be async, then IMO so should the shell_pipe_to static command. I don't know if it would be better to add an argument to the shell function, or add a separate shell_async function. There is an underlying shell_impl_async function, which is currently only used wrapped in a tokio barrier, so a change would not be too complex.

If we wanted we could enable async shell commands, but I'm not sure if thats good default behavior.

Make sense to me, thanks. Although '&' or nohup command & on the command don't work as we might need wait for the shell completes.

@alxshine
Copy link
Contributor Author

alxshine commented Dec 1, 2022

Make sense to me, thanks. Although '&' or nohup command & on the command don't work as we might need wait for the shell completes.

We could create an issue for this, and shift both the named and static pipe-to command to async.
It's just a larger rewrite and not really related to this PR.

That said, I would be happy to work on that once it's clear how such an implementation should be architected in the frame of helix's codebase.

@the-mikedavis the-mikedavis changed the title Add :pipe-to typable command that ignores shell output. Add :pipe-to typable command that ignores shell output Dec 12, 2022
@the-mikedavis the-mikedavis merged commit 0b96021 into helix-editor:master Dec 12, 2022
freqmod pushed a commit to freqmod/helix that referenced this pull request Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants