Question:

zsh: Is it possible to trace all functions and commands called and aliases expanded during a command’s execution?

Chloe: 02 February 2022

I want something like this:

# source:
a() b mp3 m4a "$@"
b() eval "${1}-to-${2} $@:q"
alias mp3-to-m4a='ffmpeg ...'
# 
$ traceall a a.mp3 a.m4a
 # should return:
 Functions:
 a
 b
 Aliases:
 mp3-to-m4a
 commands:
 ffmpeg

Answer:
Athena: 02 February 2022

You might look at trap with the DEBUG pseudosignal. This only triggers for commands and functions, though, and only after alias expansion. You want to read the details in the zsh manual, because it runs a command or function giving it information about what's about to be executed, rather than recording information directly; you could use this hypothetically to implement a full debugger.