Cygwin Command Prompt

Linux shells use the PS1 variable to determine what the command prompt should look like. This is the command prompt I use in my shell:

export PS1="\[\e]2;\u@\H - ${workSpaceName} - \w\a\e[32;1m\n\s\v - \u@\H - ${workSpaceName} - \w\n\d - \@ > \e[0m"

It gives me a prompt like this:

-bash3.2 - RobertMarkBram@orson - SCJP - /cygdrive/d/WorkSpaces/scjp
Sun Aug 03 - 11:52 PM >
And gives my shell this window title (also used in the alt+tab display). RobertMarkBram@orson - SCJP - /cygdrive/d/WorkSpaces/scjp

Edit 7/08/2008 12:35:39 PM: see my comments below.

IBM's page, Tip: Prompt magic helped me build it.

You can also use the PROMPT_COMMAND variable. The contents of this variable are executed as a regular Bash command just before Bash displays a prompt. It isn't the same as the PS1 variable, because the PROMPT_COMMAND string is actually executed, whereas PS1 is parsed to form a string.

For example, this:

export PROMPT_COMMAND='echo -ne "\nnice prompt"'

Gives me this (in combination with my PS1):

nice prompt
-bash3.2 - RobertMarkBram@orson - SCJP - /cygdrive/d/WorkSpaces/scjp
Sun Aug 03 - 11:58 PM >

The Linux BASH syntax : prompt variable can give you a bit more detail about what you can put there.

Popular Posts