I have a function in fish shell that calls a bunch of commands sequentially.
How do I add the commands that are being executed to the output?
Essentially if I had a bash script doing that I would add set -x
at the beginning. Is there a way to do that for fish shell functions?
As answered in a similar question, this feature now exists!
You can set the variable fish_trace to a non-empty value to enable echoing of the commands, similar to set -x. Erasing the variable stops the echoing again:
Emily@Peach ~> echo hell
hell
Emily@Peach ~> set fish_trace 1
Emily@Peach ~> echo hell
> echo hell
hell
Emily@Peach ~> set -e fish_trace
> set -e fish_trace
Emily@Peach ~> echo hell
hell