From f77b4eeb772c779678fa801fbc5ee82dea196895 Mon Sep 17 00:00:00 2001 From: nirenjan Date: Tue, 18 Jun 2013 11:31:27 -0700 Subject: [PATCH] Fix prompt for commands over SSH When executing commands over SSH, such as SCP, the server (tput) complains that there is no terminal defined. This fix sets the T_* variables only if the TERM variable is not empty. --- bash/bashrc.common | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/bash/bashrc.common b/bash/bashrc.common index 9bbca29..0406513 100644 --- a/bash/bashrc.common +++ b/bash/bashrc.common @@ -7,10 +7,20 @@ add_to_path() { } # Define the colors used by the prompt -T_B=$(tput setaf 4) # Blue -T_G=$(tput setaf 2) # Green -T_Y=$(tput setaf 3) # Yellow -T_S=$(tput sgr0) # Reset +if [[ ! -z $TERM && "$TERM" != "dumb" ]] +then + T_B=$(tput setaf 4) # Blue + T_G=$(tput setaf 2) # Green + T_Y=$(tput setaf 3) # Yellow + T_S=$(tput sgr0) # Reset +else + # We've probably been invoked by an SSH command, there's no terminal + # to deal with. Don't bother coloring the prompt. + T_B='' + T_G='' + T_Y='' + T_S='' +fi # Import the Git prompt shell functions. These can be found # @github:git/git/contrib/completion/git_prompt.sh