4 ms·
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 ma
by orblivion 5y ago
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?
- saagarjha 5y agoSend a SIGTERM to the editor, maybe?
- Beltalowda 5y agoAnd there's always the power button on your computer :-)
- orblivion 5y agoKind of ugly, but yeah, that's what I'd imagine doing.
- throwaway09223 5y agoIt 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.
- goodside 5y agoTo 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.
- orblivion 5y agoYeah 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).
- delusional 5y agoDepends 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/f4a811d0a1fafb3d7b0e7f514d85916ae3933942/vipe#L89 https://github.com/pgdr/moreutils/blob/f4a811d0a1fafb3d7b0e7...
- foresto 5y agoExiting vim with :cq is also handy for backing out of git commits.
- delusional 5y agoI use the mnemonic "cancel-quit" for exactly that reason.
- reayn 5y agoPressing ZQ in insert mode also provides the same effect!
- toxik 5y agoIn normal mode, not insert mode. ZQ in insert mode inserts ZQ.
- reayn 5y agoOh my bad, i had a bit of a stroke writing my comment lol.
- CGamesPlay 5y agoActually, 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.