public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Andy <AndyMHancock@gmail.com>
To: cygwin@cygwin.com
Subject: Re: Bashrc distinguish between mintty and x-windows xterm
Date: Mon, 25 Jun 2012 01:46:00 -0000	[thread overview]
Message-ID: <loom.20120625T034218-332@post.gmane.org> (raw)
In-Reply-To: <loom.20120620T050746-6@post.gmane.org>

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

  reply	other threads:[~2012-06-25  1:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-22  0:39 Andy
2012-05-22  3:09 ` Buchbinder, Barry (NIH/NIAID) [E]
2012-06-20  3:08   ` Andy
2012-06-25  1:46     ` Andy [this message]
     [not found] <CAGU3OVyzt3r+raKuFEnb1AKkqfzHQy1DPFukJSU8mQyR_3gr9g@mail.gmail.com>
2012-05-25  6:56 ` Andrew Hancock
2012-05-25 14:19   ` Buchbinder, Barry (NIH/NIAID) [E]
2012-05-25 14:53     ` Ken Jackson
2012-05-26 21:10       ` Andy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20120625T034218-332@post.gmane.org \
    --to=andymhancock@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).