This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Naming Cygwin Shells
- From: Brian Dessent <brian at dessent dot net>
- To: cygwin at cygwin dot com
- Date: Tue, 09 Oct 2007 03:24:56 -0700
- Subject: Re: Naming Cygwin Shells
- References: <13109737.post@talk.nabble.com>
- Reply-to: cygwin at cygwin dot com
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/