delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/06/24/21:47:02

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,KHOP_THREADED,NML_ADSP_CUSTOM_MED,RCVD_IN_HOSTKARMA_NO,SPF_HELO_PASS,TW_HR,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Andy <AndyMHancock AT gmail DOT com>
Subject: Re: Bashrc distinguish between mintty and x-windows xterm
Date: Mon, 25 Jun 2012 01:46:26 +0000 (UTC)
Lines: 28
Message-ID: <loom.20120625T034218-332@post.gmane.org>
References: <loom DOT 20120522T023835-645 AT post DOT gmane DOT org> <0105D5C1E0353146B1B222348B0411A20A770C7BB5 AT NIHMLBX02 DOT nih DOT gov> <loom DOT 20120620T050746-6 AT post DOT gmane DOT org>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Andy <AndyMHancock <at> gmail.com> writes:
> For the record, this in .bashrc seems to work well in xterm's white
> background > and mintty's black background.
> 
> case "$(< /proc/$PPID/exename)" in
>    */xterm) function setPS1() {
>       PS1="\[\033]0;\w\007\033[32m\]\u@\h \[\033[35m\w\033[0m\]\n$" ;
>       echo xterm
>    } ;;
>    */mintty) function setPS1() {
>       PS1="\[\e]0;\w\a\]\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$" ;
>       echo mintty
>    } ;;
> esac

Actually, the above fails if bash is invoked from a process for which
/proc/$PPID/exename doesn't exist.  For example, if I shell out of Windows-based
gvim, $PPID is 1.  I found that the following works for this case too.

function setPS1() \
   { PS1="\[\e]0;\w\a\]\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$" ; }
if [ -a /proc/$PPID/exename ]; then
   case "$(< /proc/$PPID/exename)" in
      */xterm) function setPS1() {
         PS1="\[\033]0;\w\007\033[32m\]\u@\h \[\033[35m\w\033[0m\]\n$" ;
      } ;;
   esac
fi


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019