This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Naming Cygwin Shells


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:

settitle()
{
  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.

Brian


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]