Responsive image

Recently I added a “prefix” to some prompts for some machines I have access to. This was to help differentiate between a production box and a development box that both need the same ‘hostname’ to be set in order to work properly. I set the new prompt with the following:

    export PS1="\[$(tput bold)\]\[$(tput setaf 1)\][\[$(tput bold)\]\[$(tput setaf 2)\]DEV\[$(tput bold)\]\[$(tput setaf 1)\]] \[\033[00m\]\u@\h\[\033[01;34m\] \w \[\033[00m\]\[\033[00m\]$\[\033[00m\] "

Which lead me to this error:

    tput: No value for $TERM and no -T specified

This was being spammed (usually 4 plus lines or so) when using scp to remotely access files from the machine the prompt was set on.

For reference this was closer to the top in the ~/.bashrc file:

if [[ $TERM == "xterm" ]]; then
    export TERM="xterm-256color"
elif [[ $TERM == "screen" ]]; then
    export TERM="screen-256color"
fi

After studying the if-statement snippet, I realized that there was a possibility that the $TERM variable wasn’t even being set. So I changed the snippet to this:

export TERM="xterm-256color"
if [[ $TERM == "screen" ]]; then
    export TERM="screen-256color"
fi

This appeared to have fixed the issue and all things are working well now.

EDIT: As nyuszika7h pointed out in the comments the first part of the if-statement is made redundant by the code change.


Comments

comments powered by Disqus


~ About me ~
I am a human who enjoys writing code.
~ Follow me ~
~ GitHub Recent Activity ~

Status updating...

~ Interesting Links ~