1

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?

Xobb
  • 1,075
  • 6
  • 8
  • 1
    Does this answer your question? [Printing executed commands](https://stackoverflow.com/questions/34151443/printing-executed-commands) – Smar Jul 17 '22 at 06:04

2 Answers2

3

Sadly there's no good way to do this now. You can invoke fish as fish -d 3 but that's more for debugging output.

ridiculous_fish
  • 17,273
  • 1
  • 54
  • 61
  • Although I have a tension to accept this answer, but fish shell users should not accept it and settle down for this. Going to github to make an feature request. – Xobb May 10 '19 at 02:25
3

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
emdash
  • 80
  • 1
  • 9