Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have the following shell script function from this site that allows me to change the title in both Putty and Cygwin. In Putty connected to a Linux host it changes the title and leaves the prompt as it was. But in Cygwin it changes the title and then the prompt becomes a mere $ or # sign.

I would like to create a version for Cygwin that changes the title but leaves the prompt as it was. (I know I should try to create one first on my own before posting here but prompt strings I have always found confusing.)

EDIT: More specifically, in Cygwin I like the default prompt of user@hostname followed by the current directory. I'd like to preserve THAT prompt.

EDIT II: And I don't really care if the colors of the default Cygwin prompt are preserved, if that makes it easier. I just want at the very least the directory in the prompt.

Here's what I have:

function wtitle {
  if [ "$TERM" == "xterm" ] ; then
    # Remove the old title string in the PS1, if one is already set.
    PS1=`echo $PS1 | sed -r 's/^\\\\\[.+\\\\\]//g'`
    export PS1="\[\033]0;$1 - \u@\h:\w\007\]$PS1"
  else
    echo "You are not working in xterm. I cannot set the title."
 fi
}

`

share|improve this question

1 Answer 1

Please add

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

as last line in your ~/.bashrc and login again or just run

source ~/.bashrc
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.