I would like to be able to programmaticly detect when my pushd
stack is non-empty, within a bash shell. Is there any way to detect this?
Something akin to $SHLVL would be nice. But so far, the only solution I've found is to wrap pushd
and popd
with aliases that parse the output of the originals to detect the depth. While that would work, it doesn't feel particularly elegant. (Clearly, the information is stored somewhere in the environment.)
My reason is, I wish to adorn my bash prompt with a pushd depth-count, when this is the case.