Mikael Berthe is a user on mamot.fr. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.

#bash stumper: if you're performing input via stdin (e.g. `cat -`), how the heck do you get #vi mode to work or otherwise have any control over editing?
#commandline #cli #editor

@kemonine i don't want to add to the command line. i'm already in stdin. i can edit a command line easy with vi mode. but being in stdin is the issue.

Mikael Berthe @McKael

@wxl Not sure exactly what your use case is, but you might have a look at vipe(1) if you don't know about it. It's in the moreutils package on my system.

command1 | vipe | command2
» vipe allows you to run your editor in the middle of a unix pipeline and edit the data that is being piped between programs.

@kemonine

· Web · 2 · 2

@McKael @wxl Oh that is just cool!

You win the internets for a couple hours on that one.

@McKael @kemonine that's a really cool program I did not know about, but not what I'm looking for.

Imagine you have already executed `cat -`. You're now in stdin. Let's say you want to edit your input before EOF. How does one do that?

@wxl @McKael Could you do cat - | vipe ?

That might be a reasonable way to work the issue.

@kemonine @McKael yes but my use case hinges on the assumption it's already executed.

@wxl @McKael Damn.

I wonder if it's more a function of the shell you're using than the actual stdin vs stdout type stuff.

Does ZSH/tmux/screen offer a way to mung output after that command has already been executed?

I'd also suggest sh or csh but... I have a feeling they likely won't be capable of what you're looking for.

@wxl @kemonine I don't think you can, since stdin is usually a stream. I guess you shouldn't use cat in the first place... :)

If you just want to edit a text and stream it to the standard input of a command, maybe you can use something like Vim (and use ":w !command") ?