fix color if not a TTY, add check for grid env and minor refactoring
Merge pull request #3979 from spigad/master

voms check and color vs TTY