Hacker News

Ask HN: Extendable" Shell Commands?

I often find myself in the situation where I fire off a long-running process in the shell and then want to do something as a follow-up, at which point it is too late to add that '&& foo || bar' at the end of the line.

Simple example: Download this Linux ISO.. Oh, and flash it to my USB drive... Oh, and check the shasum... Oh, and show a notification when done.

Then the next time I want a slight variation of something more complex, every time I'm weighing the running time of the first process vs the time to type out or modify the second part.

I could open a separate shell and spawn a second process waiting for the first to finish but rarely worth the overhead of doing that.

So what I'd like is a "chainable shell" or "living prompt", where I can type out whatever comes next as the last shell command is already and still running in the foreground. Depending on the program, I noticed this kind-of already works where bash will actually go ahead and run whatever I type in the middle of the output of a blocking process once it's finished. But only for some programs.

Feels like something that hits most of us and should be possible to make something in bash/zsh for triggered by a keyboard shortcut. Yet I've never seen anything for this.

Anyone hacked together or found something like this that they use and would like to share?