screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatic title-ing in screen


From: Phil!Gregory
Subject: Re: Automatic title-ing in screen
Date: Wed, 29 Dec 2004 09:37:08 -0500
User-agent: Mutt/1.5.6+20040907i

* address@hidden <address@hidden> [2004-12-28 22:21 -0500]:
> Does anyone have a working sample of the hack described in the section
> "TITLES" of the man page.

No, but I can probably fake it.

Let's say that you're using the default Debian prompt:

  PS1="address@hidden:\w\$ "

The longest string that won't change at the end of your prompt is "$ "
(unless you're root, but we'll ignore that).  So, in your .screenrc, you
put:

  shelltitle "$ |bash"

This tells screen to look for the string "$ " to mark the end of a prompt
(anything after that is the new title of the window).  If it's sitting at
a prompt, use "bash" as the window title.

You also need to modify your prompt to have that null
title-escape-sequence:

  PS1='address@hidden:\w\$ '

That should do it.  I just tested this myself and it appears to work.

Personally, I don't bother with that.  I use zsh, which has the preexec()
function.  preexec() is run just after you type a command, and is given
the command in a single string as its first argument.  My preexec looks
like this:

  setopt extended_glob
  preexec () {
      if [[ "$TERM" == "screen" ]]; then
          local CMD=${1[(wr)^(<*|*=*|sudo|exec|-*)]}
          echo -n "\ek$CMD\e\\"
      fi
  }

As far as I can tell, bash has no similar functionality, so you're stuck
with the screen shelltitle stuff.

-- 
...computer contrarian of the first order... / http://aperiodic.net/phil/
PGP: 026A27F2  print: D200 5BDB FC4B B24A 9248  9F7A 4322 2D22 026A 27F2
--- --
The truth of a proposition has nothing to do with its credibility.  And
vice versa.
---- --- --




reply via email to

[Prev in Thread] Current Thread [Next in Thread]