Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The one I use the most is `vipe`.

> vipe: insert a text editor into a pipe

It's useful when you want to edit some input text before passing it to a different function. For example, if I want to delete many of my git branches (but not all my git branches):

  $ git branch | vipe | xargs git branch -D
`vipe` will let me remove some of the branch names from the list, before they get passed to the delete command.


I mostly rely on fzf for stuff like this nowadays. You can replace vipe with fzf —multi for example and get non-inverted behavior with fuzzy search.

More to it, not in a pipe (because of poor ^C behavior), but using a hokey in zsh to bring up git branch | fzf, select any number of branches I need and put them on command line, this is extremely composable.


I vaguely recall in ~2010 coming across a Plan 9 manpage(?) that seemed to imply that Emacs could work that way in a pipe (in reference to complex/bloated tools on non-Plan 9 systems), but that wasn't true of any version of Emacs I'd ever used.


Yep, set EDITOR to emacsclient and vipe will use emacs.


I mean that it seemed to suggest that you could pipe directly to Emacs, without using vipe.


And what if you decide mid-vipe "oh crap I don't want to do this anymore"? In the case of branches to delete you could just delete every line. In other cases maybe not?


Depends on your editor i suppose, but vipe checks the exit code of it [1]. In vim you can exit with an error using :cq

[1]: https://github.com/pgdr/moreutils/blob/f4a811d0a1fafb3d7b0e7...


Exiting vim with :cq is also handy for backing out of git commits.


I use the mnemonic "cancel-quit" for exactly that reason.


Pressing ZQ in insert mode also provides the same effect!


Actually, it doesn’t. ZQ is the same as :q! which quits without saving with a 0 exit code. So all of your git branches get deleted in this example, since you left the file as it was. You definitely want :cq here.


In normal mode, not insert mode. ZQ in insert mode inserts ZQ.


Oh my bad, i had a bit of a stroke writing my comment lol.


To be fair, that scenario would be just as bad or worse without vipe.

Also, you can construct your pipeline so that a blank file (or some sentinel value) returned from vipe means “abort”. A good example of this is when git opens your editor for interactive merging — deleting all lines cancels the whole thing.


Yeah you could just as well say "oh crap I didn't mean to do that" after finishing a non-interactive command. However, at least knowing my own lazy tendencies, I could imagine feeling comfortable hitting <enter> on this command without a final careful review, because part of me thinks that I can still back out, since the interactive part isn't finished yet.

But maybe not. I haven't tried it yet (and it does seem really useful).


It will depend on the commands in question. The entire unix pipeline is instantiated in parallel, so the commands following vipe will already be running and waiting on stdin.

You could kill them before exiting the editor, if that's what you want. Or you could do something else.

The other commands in the pipeline are run by the parent shell, not vipe, so handling this would not be vipe specific.


Send a SIGTERM to the editor, maybe?


And there's always the power button on your computer :-)


Kind of ugly, but yeah, that's what I'd imagine doing.


This is useful - I usually either use an intermediate file or a bunch of grep -v


the editor "micro" can be used as a pipe editor. it's a feature. And without using temp file tricks as vipe does. echo 'test' | micro | cat




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: