Fish Shell – Kill %1 Equivalent Command

fishjob-controlkill

In bash, if I run kill %1, it kills a backgrounded command in the current shell (the most recent one, I believe).

Is there an equivalent of this in fish? I haven't been able to find it online in a bit of web searching.

I'm not sure if I did it wrong, but

$ ps
    PID TTY          TIME CMD
  73911 pts/5    00:00:00 fish
  73976 pts/5    00:00:00 ps
$ sleep 100
^Z⏎
$ kill %1
$ ps
    PID TTY          TIME CMD
  73911 pts/5    00:00:00 fish
  74029 pts/5    00:00:00 sleep
  74121 pts/5    00:00:00 ps

Best Answer

Your command has worked, but because the job is stopped it has not responded to the signal.

From your example where it didn't seem to work, try continuing the process with fg or bg, or forcibly terminate the process with kill -SIGKILL %1, and it will exit.

kill %1 works immediately in bash and zsh because it is a builtin command in these shells and sends SIGCONT in addition to SIGTERM (or the specified signal).