> Where I want output, I protect it with: > > [ -n "$PS1" ] && printf … Maybe consider: [[ -t 1 ]] && printf ...