All pastes #1832123 Raw Edit

jon-prompt

public shellscript v1 · immutable
#1832123 ·published 2010-03-10 17:21 UTC
rendered paste body
## Scp/sftp has issues with tput colorized bash prompt.## The problem is tput outputs non-printing chars.## A non-obvious issue, and ONLY promlem w/bash.## fix: negate dumb terms from having prompts.if [ $TERM = "dumb" ] ;then  return      # The return call makes the sourcing of .bashrc go back to the calling script (usually .profile or .bash_profile).      # The assumption is that ANY interactive .bashrc setup is pointless once the term is detected as "DUMB"      # This is an area for debate - change me if you want.else  # Root gets a RED prompt  # User gets a BLU prompt  # NOTE: Solaris ID prog must support '-u' naked uid output.  if [ "`id | cut -d\( -f1 | cut -c5-`" -eq "0" ];  then   PS1="\\[`tput setaf 1`\\]\\[`tput bold;`\\][\\[`tput sgr0`\\]\\u\\[`tput setaf 1`\\]\\[`tput bold;`\\]@\\[`tput sgr0`\\]\\h\\[`tput setaf 1`\\]\\[`tput bold;`\\]:\\[`tput sgr0`\\]\\[`tput bold;`\\]\\W\\[`tput sgr0`\\]\\[`tput setaf 1`\\]\\[`tput bold;`\\]]\\[`tput sgr0`\\]\\[`tput setaf 7`\\]# \\[`tput sgr0`\\]"         PS2="\\[`tput setaf 1`\\]\\[`tput bold;`\\]>  \\[`tput sgr0`\\]"  else   PS1="\\[`tput setaf 4`\\]\\[`tput bold;`\\][\\[`tput sgr0`\\]\\u\\[`tput setaf 4`\\]\\[`tput bold;`\\]@\\[`tput sgr0`\\]\\h\\[`tput setaf 4`\\]\\[`tput bold;`\\]:\\[`tput sgr0`\\]\\[`tput bold;`\\]\\W\\[`tput sgr0`\\]\\[`tput setaf 4`\\]\\[`tput bold;`\\]]\\[`tput sgr0`\\]\\[`tput setaf 7`\\]$ \\[`tput sgr0`\\]"         PS2="\\[`tput setaf 4`\\]\\[`tput bold;`\\]>  \\[`tput sgr0`\\]"  fifi