bashconsoleps1

$MSYSTEM variable in bashrc


NOTE

I am using Windows 7. On installing msysgit and GitHub for Windows, I found that git bash can be called from the folders. I opened up the terminal and first thing I wanted was to change how it displays in the console.

Here is what echo $PS1 gave me:

\[\033]0;$MSYSTEM:\w\007 \033[32m\]\u@\h \[\033[33m\w$(__git_ps1)\033[0m\] $ 

I've been modifying my bash's PS1 for some time now, and know most of the content there is. But I have never ever seen $MSYSTEM before.

Google resulted in nothing except some results about using it to set $MSYSTEM=MINGW32 which of course isn't the case here.

So, what does MSYSTEM variable do? Also, when I create a file .bashrc and put this line there; the terminal now shows a blank-space just before my username. This is because of the empty space in this segment \007 \033 but it was absent before. Here are the screenshots when I use a custom .bashrc and when I don't:

Without <code>bashrc</code>

Without bashrc

With <code>.bashrc</code>

With bashrc

I know why the newline is absent from my customized terminal; but the questions are:


Solution

  • It sets the Window title to the value of MSYSTEM variable. As far as the space, it looks like you messed up the final newline, notice carefully

    export PS1='\[\033]0;$MSYSTEM:\w\007
    \033[32m\]\u@\h \[\033[33m\w\033[0m\]
    $ '
    

    in the variable above each start of a new line insert a literal newline character into the PS1.

    How to change the title of an xterm