This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bashrc distinguish between mintty and x-windows xterm


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]