Change Cygwin Prompt

The PS1 environment variable controls the prompt:

PS1='\w $ '

For more information on this and other prompt configuration topics, type man bash (assuming bash is your shell) and see the "PROMPTING" section.

To make this change permanent, edit your ~/.bashrc file to add the above line.


A login shell is one whose first character of argument zero is a -, or one started with the --login option. When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.

So it depends...i dont't use the --login, so i must add it to ~/.bashrc


Not sure why having less context is better than having more... The fact that there is a new line in the prompt means the length of the prompt should not be an issue, but try this:

PS1='\[\e[1;33m\]\w\n\[\e[1;36m\]\$\[\e[0m\] '

or

export PS1='\[\e[1;33m\]\w\n\[\e[1;36m\]\$\[\e[0m\] '

This gives you a coloured prompt:

/full/path/to/current/folder
$your command text here

That way, you always see your full folder context but still get a full line to input text. (I left out the customary space following the '$' because it's coloured for clarity).

Colours are:
    1. '/full/path/...' = yellow;
    2. '$' (on next line) = cyan;
    3. 'your command text...' = light grey.

For those who DO want the 'user@hostname ' context too:

PS1='\[\e[1;32m\]\u\[\e[1;35m\]@\[\e[1;32m\]\h \[\e[1;33m\]\w\n\[\e[1;36m\]\$\[\e[0m\] '

or

export PS1='\[\e[1;32m\]\u\[\e[1;35m\]@\[\e[1;32m\]\h \[\e[1;33m\]\w\n\[\e[1;36m\]\$\[\e[0m\] '

This gives you a coloured prompt:

user@hostname /full/path/to/current/folder
$your command text here

This is my preference.

Colours are:
    1. 'user' = (light) green;
    2. '@' = pink;
    3. 'hostname' = (light) green;
    4. '/full/path/...' = yellow;
    5. '$' (on next line) = cyan;
    6. 'your command text...' = light grey.

(No, there are no spelling mistakes in this post - Queen's English ;) )


.bashrc didn't work for me. I added this to the end of /etc/profile and it worked:

export PS1="\[\e[33m\]\w\[\e[0m\] \$ "

I'm using Cygwin version 2.11.2 (latest version as of 2018-12-18).