This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: Bashrc distinguish between mintty and x-windows xterm
- From: "Buchbinder, Barry (NIH/NIAID) [E]" <BBuchbinder at niaid dot nih dot gov>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>, Andy <AndyMHancock at gmail dot com>
- Date: Mon, 21 May 2012 23:08:55 -0400
- Subject: RE: Bashrc distinguish between mintty and x-windows xterm
- References: <loom.20120522T023835-645@post.gmane.org>
Andy sent the following at Monday, May 21, 2012 8:39 PM
>My bashrc sets the color of the prompt depending on $TERM. My x-windows
>xterm has a white background and the cygwin default terminal, which has
>a black background, use to not have $TERM=xterm. I could distinguish
>between them in the bashrc script, and set the prompt colours
>accordingly. Now with mintty emulating an xterm, $TERM takes on the
>string "xterm" (but it has a black background). I would like to find a
>simple bash script way to tell the difference between when bashrc is
>being called from a mintty versus an actual x-windows xterm. Can anyone
>suggest a way?
(Not totally tested. YMMV.)
# Only set ThisTerm if not set.
if [ -z "${ThisTerm}" ]
then
if [ ${PPID} = 1 ]
then
ThisTerm=cmd
else
if [ "$(cat /proc/${PPID}/exename)" = '/usr/bin/mintty' ]
then
ThisTerm=mintty
else
# not minty, not cmd, so xterm
ThisTerm=xterm
fi
fi
fi
Then set colors by the value of ThisTerm.
- Barry
Disclaimer: Statements made herein are not made on behalf of NIAID.
--
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