Use the env's PROMPT_COMMAND for resetting xterm titles when available.
authorJason Stubbs <jstubbs@gentoo.org>
Sun, 25 Dec 2005 07:42:00 +0000 (07:42 -0000)
committerJason Stubbs <jstubbs@gentoo.org>
Sun, 25 Dec 2005 07:42:00 +0000 (07:42 -0000)
Otherwise use ${user}@${hostname}:${cwd}.

svn path=/main/trunk/; revision=2454

pym/output.py

index 69dcb5390f8564ae4b07c5f33ebc0073293331c6..ec538f273520172271d8db6e4b163fc9e1de7685 100644 (file)
@@ -3,7 +3,7 @@
 # $Id: /var/cvsroot/gentoo-src/portage/pym/output.py,v 1.24.2.4 2005/04/17 09:01:55 jstubbs Exp $
 
 
-import os,sys,re
+import commands,os,sys,re
 
 havecolor=1
 dotitles=1
@@ -102,11 +102,12 @@ def xtermTitle(mystr):
                                sys.stderr.flush()
                                break
 
-def xtermTitleReset():
-       if havecolor and dotitles and os.environ.has_key("TERM"):
-               myt=os.environ["TERM"]
-               xtermTitle(os.environ["TERM"])
+prompt_command = os.getenv("PROMPT_COMMAND", 'echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"')
+default_xterm_title = commands.getoutput(prompt_command)
+del prompt_command
 
+def xtermTitleReset():
+       xtermTitle(default_xterm_title)
 
 def notitles():
        "turn off title setting"