Some small zsh/bash code improvements

For your consideration; can be cherry-picked separately.