fish Shell: Chaining commands to be run as a background job

Viewed 988

I'd like to be something along the following at the fish command prompt:

$ sleep 120; and echo 'buggery bollocks' &

Or, as of fish 3.0:

$ sleep 120 && echo 'buggery bollocks' &

Or either of the above without the trailing ampersand, then suspending with Ctrl-Z and putting the whole thing into the background with 'bg' command. None of these work. The first two just do the sleep in the foreground, and I assume the echo in the background. If I suspend with Ctrl-Z, then 'buggery bollocks' gets output immediately.

I know I could just write a script with those two commands in it, and run it in the background, but I feel I shouldn't have to. Any experienced fishmongers around who might have an answer for me?

Thanks!

2 Answers

Fish does not currently support backgrounding anything more complicated than a simple external command.

So as of fish 3.1.2 (and most likely 3.2.0): Yes, you have to write a script with those two commands in it and run it in the background.

As @faho said fish doesn't support background processes yet, but there is a "hackish" way to do it.

fish -c 'my_command_1' & fish -c 'another_cmd' & fish -c '3rd_cmd' 

I use this to start browser-sync and upload scripts in 1 cmd when I develop.

Related