Naming Cygwin Shells

Brian Dessent
Tue Oct 9 10:28:00 GMT 2007

bluewolf wrote:

> Simple question here. I am trying to figure out a way to name a cygwin shell
> so that I can have multiple windows up doing tails and other such functions
> and easily see what system i am looking at.
> I know that in CMD if i want to change the name of a CMD window to shellname
> the command the command is simply> title shellname

The default prompt has escape sequences that change the window title, so
that it contains the current working directory.  So unless you change
PS1, no matter what you do to set the title it will be overwritten on
the next prompt.

You can do this with a simple shell function.  For example, with the
following in your ~/.bashrc:

  local t=$1
  if [ "x$t" == "x" ]; then t='\w'; fi
  PS1=$(perl -e '$_ = $ENV{PS1}; s,(\\e]0;).*(\\a),$1$ARGV[0]$2,i;
                 print' "$t")

... then you can just

settitle foo

or if it contains spaces:

settitle "foo bar"

or even including prompt escape sequences like:

settitle "dir: \w tty: \l foo bar"

or just "settitle" to get the default of \w.


Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list