delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/10/09/06:28:17

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <470B56F8.23B485B7@dessent.net>
Date: Tue, 09 Oct 2007 03:24:56 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Naming Cygwin Shells
References: <13109737 DOT post AT talk DOT nabble DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019