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 Subject: Re: Bashrc distinguish between mintty and x-windows xterm Date: Wed, 20 Jun 2012 03:08:07 +0000 (UTC) Lines: 37 Message-ID: References: <0105D5C1E0353146B1B222348B0411A20A770C7BB5 AT NIHMLBX02 DOT nih DOT gov> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: List-Subscribe: List-Archive: List-Post: List-Help: , 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 wrote: | Ken Jackson jackson.io> writes: |> ==== Fri, May 25, 2012 at 09:32AM -0400 Buchbinder, Barry |> (NIH/NIAID) [E] wrote: |>> Andrew Hancock sent the following at Friday, May 25, 2012 12:42 AM |>>>Barry, it works flawlessly. Thanks immensely! |>> |>> But I forgot to export ThisTerm, otherwise it is always unset when |>> a subshell is launched. |> |> Access to the /proc file system is fast, so you could forgo the |> variable and access it directly: |> |> case "$(< /proc/$PPID/exename)" in |> */xterm) echo "This is an xterm" ;; |> */mintty) echo "This is a mintty" ;; |> esac | |Barry, Ken, | |Thanks for your valuable scripting examples. It sent me scurrying back to the |man page to figure out case/esac and command substitution. It's also a good |reminder of the wealth of detail available in /proc. 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 -- 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