public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* setting cygwin terminal (mintty) title from a very remote system
@ 2014-04-11 19:13 Ross Boylan
  2014-04-11 20:00 ` Adam Dinwoodie
  2014-04-12  0:49 ` Duncan Roe
  0 siblings, 2 replies; 5+ messages in thread
From: Ross Boylan @ 2014-04-11 19:13 UTC (permalink / raw)
  To: cygwin

I typically connect to systems through several hops; this note is about 
how I managed to set the title of the cygwin terminal to match the 
remote system.  Usually it just shows the name on the first hop only.   
I would love to learn there is a better way to get the same results.

Various internet sources advise things like

echo -ne '\e]0;Title\a'

to set the window title while noting that the default cygwin prompt sets 
this automatically.  This did not work for me initially, but I found a 
way to get it to work.

On the remote system the prompt does not contain any window titling 
commands.

Concretely, my connection sequence looks like this.

 From System A, running Windows 7, launch a cygwin bash shell.
In that shell, ssh to system B.  B's name will appear in the title bar.
 From B ssh to C.  Neither this nor later operations change the title bar.
 From C ssh to D.
On D, run screen.
In screen, run emacs.
In emacs start a (bash) shell.

I want the name of system D to appear in my title bar.
Systems B-D are running various versions of Debian GNU/Linux.
The echo command from within the bash prompt is ineffective.

If I start a new shell from within screen (Ctl-a c), the echo command 
works from there.

I suppose if I built the window setting command into the remote prompt 
things would just work, since I launch emacs from such a prompt.  But 
I'm not sure what that would do if I were not connecting via cygwin.

Ross Boylan

Someone put in a request for a feature to support manually setting the 
title; this was rejected on the grounds that echoing an appropriate 
sequence would do the same thing 
(http://code.google.com/p/mintty/issues/detail?id=241). Unfortunately, 
that does not seem to be true after connecting to a remote system, or at 
least it is not true after the sequence of steps described above. 
http://superuser.com/questions/362227/how-to-change-the-title-of-the-mintty-window 
has a comment that the echo has no effect when issued from within screen.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: setting cygwin terminal (mintty) title from a very remote system
  2014-04-11 19:13 setting cygwin terminal (mintty) title from a very remote system Ross Boylan
@ 2014-04-11 20:00 ` Adam Dinwoodie
  2014-04-14 18:19   ` David Conrad
  2014-04-12  0:49 ` Duncan Roe
  1 sibling, 1 reply; 5+ messages in thread
From: Adam Dinwoodie @ 2014-04-11 20:00 UTC (permalink / raw)
  To: cygwin

On Fri, Apr 11, 2014 at 12:13:07PM -0700, Ross Boylan wrote:
> I typically connect to systems through several hops; this note is
> about how I managed to set the title of the cygwin terminal to match
> the remote system.  Usually it just shows the name on the first hop
> only.   I would love to learn there is a better way to get the same
> results.
> 
> Various internet sources advise things like
> 
> echo -ne '\e]0;Title\a'
> 
> to set the window title while noting that the default cygwin prompt
> sets this automatically.  This did not work for me initially, but I
> found a way to get it to work.
> 
> On the remote system the prompt does not contain any window titling
> commands.
> 
> Concretely, my connection sequence looks like this.
> 
> From System A, running Windows 7, launch a cygwin bash shell.
> In that shell, ssh to system B.  B's name will appear in the title bar.
> From B ssh to C.  Neither this nor later operations change the title bar.
> From C ssh to D.
> On D, run screen.
> In screen, run emacs.
> In emacs start a (bash) shell.
> 
> I want the name of system D to appear in my title bar.
> Systems B-D are running various versions of Debian GNU/Linux.
> The echo command from within the bash prompt is ineffective.
> 
> If I start a new shell from within screen (Ctl-a c), the echo
> command works from there.

Fundamentally, this is nothing to do with Cygwin.  MinTTY will change
the terminal title if it receives the escape sequence to do so.  The
title will stay the same if something intercepts that sequence, and it
will probably appear to stay the same if something resets it immediately
(many Bash shell prompts do just that).

When you type at that shell, your keystrokes are passed from MinTTY
through to the first ssh session, through to the second, through to the
third, through to Screen, through to Emacs, through to the final Bash
shell.  Characters printed back, including the escape characters that
set the terminal, go through the same sequence in reverse.  Something in
that chain, for you, is intercepting those escape characters.

We don't have access to your setup to work out where that is.  I'd
suggest going step-by-step through each connection and trying to change
the terminal title, to work out where it is.  At that point you need to
work out *why* the change isn't working, and since this really doesn't
sound like a Cygwin problem, this isn't the right place to get help.
I'd suggest asking a question on Super User.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: setting cygwin terminal (mintty) title from a very remote system
  2014-04-11 19:13 setting cygwin terminal (mintty) title from a very remote system Ross Boylan
  2014-04-11 20:00 ` Adam Dinwoodie
@ 2014-04-12  0:49 ` Duncan Roe
  1 sibling, 0 replies; 5+ messages in thread
From: Duncan Roe @ 2014-04-12  0:49 UTC (permalink / raw)
  To: cygwin

On Fri, Apr 11, 2014 at 12:13:07PM -0700, Ross Boylan wrote:
> I typically connect to systems through several hops; this note is about how
> I managed to set the title of the cygwin terminal to match the remote
> system.  Usually it just shows the name on the first hop only.   I would
> love to learn there is a better way to get the same results.
>
> Various internet sources advise things like
>
> echo -ne '\e]0;Title\a'
>
> to set the window title while noting that the default cygwin prompt sets
> this automatically.  This did not work for me initially, but I found a way
> to get it to work.
>
> On the remote system the prompt does not contain any window titling
> commands.
>
> Concretely, my connection sequence looks like this.
>
> From System A, running Windows 7, launch a cygwin bash shell.
> In that shell, ssh to system B.  B's name will appear in the title bar.
> From B ssh to C.  Neither this nor later operations change the title bar.
> From C ssh to D.
> On D, run screen.
> In screen, run emacs.
> In emacs start a (bash) shell.
>
> I want the name of system D to appear in my title bar.
> Systems B-D are running various versions of Debian GNU/Linux.
> The echo command from within the bash prompt is ineffective.
>
> If I start a new shell from within screen (Ctl-a c), the echo command works
> from there.
>
> I suppose if I built the window setting command into the remote prompt
> things would just work, since I launch emacs from such a prompt.  But I'm
> not sure what that would do if I were not connecting via cygwin.
>
> Ross Boylan
>
> Someone put in a request for a feature to support manually setting the
> title; this was rejected on the grounds that echoing an appropriate sequence
> would do the same thing
> (http://code.google.com/p/mintty/issues/detail?id=241). Unfortunately, that
> does not seem to be true after connecting to a remote system, or at least it
> is not true after the sequence of steps described above. http://superuser.com/questions/362227/how-to-change-the-title-of-the-mintty-window
> has a comment that the echo has no effect when issued from within screen.
>
It is simply inappropriate to try to set the window title from the bash prompt.
Remove any and all attempts to do that from PS1 and instead  put them in
PROMPT_COMMAND which bash will obey at every prompt. This may look like
overkill, but will reset the window name should any command you run have changed
it. E.g. I have

PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}:${PWD/#$HOME/~}\007"'

Try it,

Cheers ... Duncan.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: setting cygwin terminal (mintty) title from a very remote system
  2014-04-11 20:00 ` Adam Dinwoodie
@ 2014-04-14 18:19   ` David Conrad
  2014-04-15  0:20     ` Ross Boylan
  0 siblings, 1 reply; 5+ messages in thread
From: David Conrad @ 2014-04-14 18:19 UTC (permalink / raw)
  To: Andrey Repin

On Fri, Apr 11, 2014 at 4:00 PM, Adam Dinwoodie wrote:
> On Fri, Apr 11, 2014 at 12:13:07PM -0700, Ross Boylan wrote:
>>
>> echo -ne '\e]0;Title\a'
>>
>
> [The] title will stay the same if something intercepts that sequence, and it
> will probably appear to stay the same if something resets it immediately
> (many Bash shell prompts do just that).
>

The fact that something else might reset it *immediately after* you
set it is really important. It can make it look like something you are
trying doesn't work **when it actually does work**.

I would suggest using a command like this to test setting it:

echo -ne "\e[0;This is a test\a"; sleep 5

That way, the title, if it's getting set at all, will remain set for a
few seconds before it gets reset, so you can see it. That will allow
you to tell the difference between a problem where the escape sequence
is never reaching mintty because something is eating it, and one where
the escape sequence is getting through just fine, but something, like
the bash PS1 prompt, is immediately overwriting it.

Good luck.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: setting cygwin terminal (mintty) title from a very remote system
  2014-04-14 18:19   ` David Conrad
@ 2014-04-15  0:20     ` Ross Boylan
  0 siblings, 0 replies; 5+ messages in thread
From: Ross Boylan @ 2014-04-15  0:20 UTC (permalink / raw)
  To: David Conrad; +Cc: Andrey Repin

On Mon, 2014-04-14 at 14:19 -0400, David Conrad wrote:
> On Fri, Apr 11, 2014 at 4:00 PM, Adam Dinwoodie wrote:
> > On Fri, Apr 11, 2014 at 12:13:07PM -0700, Ross Boylan wrote:
> >>
> >> echo -ne '\e]0;Title\a'
> >>
> >
> > [The] title will stay the same if something intercepts that sequence, and it
> > will probably appear to stay the same if something resets it immediately
> > (many Bash shell prompts do just that).
> >
> 
> The fact that something else might reset it *immediately after* you
> set it is really important. It can make it look like something you are
> trying doesn't work **when it actually does work**.

I agree, but I'm quite sure that's not my problem.  I only have the
problem inside emacs (usually inside screen, but it doesn't seem to
matter).  The title I'm seeing is from a different system, earlier in
the ssh chain.  I tried it (using ], not [) and it didn't work; instead
some characters appeared in the emacs window.  I also checked PS1 and
COMMAND_PROMPT; neither was generating any special characters.  Setting
COMMAND_PROMPT to the echo command simply puts the characters in front
of the command line.

Ross
> 
> I would suggest using a command like this to test setting it:
> 
> echo -ne "\e[0;This is a test\a"; sleep 5
> 
> That way, the title, if it's getting set at all, will remain set for a
> few seconds before it gets reset, so you can see it. That will allow
> you to tell the difference between a problem where the escape sequence
> is never reaching mintty because something is eating it, and one where
> the escape sequence is getting through just fine, but something, like
> the bash PS1 prompt, is immediately overwriting it.
> 
> Good luck.
> 
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> 



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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-15  0:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-11 19:13 setting cygwin terminal (mintty) title from a very remote system Ross Boylan
2014-04-11 20:00 ` Adam Dinwoodie
2014-04-14 18:19   ` David Conrad
2014-04-15  0:20     ` Ross Boylan
2014-04-12  0:49 ` Duncan Roe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).