I recently upgraded (with
apt-get dist-upgrade) my Kubuntu and Lubuntu Linux boxes, and now every time I log into one of these machines, I get this message:
tput: No value for $TERM and no -T specified
Here is a screenshot of the exact message:
This happened on both my Lubuntu machine and Kubuntu machine, and it wasn't a problem until after I upgraded; so I suspect that it was not user error.
How can I fix this?
I have tracked this down to my .bashrc file, which is getting called by my .profile file. Though, the fact that my .bashrc file now runs when I do a GUI login whereas it didn't before I upgraded is a bit weird. And no, I haven't modified my .bashrc file or my .profile recently. Also, bash isn't my default shell.
The problem is that I am calling
tput in my .bashrc file to set up variables for use in adding color to the prompt. But at the (inappropriate) time when my .bashrc file now gets run,
$TERM is not set.
fgRed=$(tput setaf 1) ; fgGreen=$(tput setaf 2) ; fgBlue=$(tput setaf 4) fgMagenta=$(tput setaf 5) ; fgYellow=$(tput setaf 3) ; fgCyan=$(tput setaf 6) fgWhite=$(tput setaf 7) ; fgBlack=$(tput setaf 0) bgRed=$(tput setab 1) ; bgGreen=$(tput setab 2) ; bgBlue=$(tput setab 4) bgMagenta=$(tput setab 5) ; bgYellow=$(tput setab 3) ; bgCyan=$(tput setab 6) bgWhite=$(tput setab 7) ; bgBlack=$(tput setab 0)
Updated question: How should I fix this? Should I set
$TERM myself? Or should I just not set these variables if
$TERM is not set?
One solution I tried was to check whether
$TERM was set. But this didn't seem to work; I still got the same error message. Here's the code:
if [ ! "$TERM" = "" ]; then #Do stuff here fi
$TERM was set, but
tput still concluded it wasn't.