Distinguishing local and remote access in shell (TERM-related)

Solution 1:

Assuming you're using Bash, in your ~/.bashrc:

if [[ $SSH_TTY ]]
then
    TERM=xterm-color
else
    TERM=xterm-256color
fi
export TERM