Tracking down a bug in the jagged mountains of shell files that are my zsh
configuration can be tough. Enter the
SOURCE_TRACE option, settable with the
-o flag when opening a new shell with the zsh command.
zsh -o SOURCE_TRACE
+/etc/zsh/zshenv:1> <sourcetrace> +/etc/zsh/zshrc:1> <sourcetrace> +/home/chris/.zshrc:1> <sourcetrace> +/home/chris/.sharedrc:1> <sourcetrace> +/home/chris/.zshrc.local:1> <sourcetrace>
The above output is an abbreviated representation of the actual files loaded on my system. I have language manager
asdf installed which adds a couple of entries. I am an
rvm user which adds 50 (!!!) entries. Lots of shell code to source for rvm. Additionally, I use Hashrocket’s dotmatrix which adds even more entries. Lots of sourcing to sort through.
This is handy in combination with print line (or
echo) debugging. It gives your print lines added context with things get noisy.