Patch by marienz to generate default_xterm_title just in time with python instead...
authorZac Medico <zmedico@gentoo.org>
Tue, 21 Feb 2006 01:16:56 +0000 (01:16 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 21 Feb 2006 01:16:56 +0000 (01:16 -0000)
svn path=/main/trunk/; revision=2755

pym/output.py

index ac57fe36677a166114bcd6a06eedbab1035db52a..e361e063d66f1737cc2a658d52433f19bddb8d6f 100644 (file)
@@ -102,11 +102,21 @@ def xtermTitle(mystr):
                                sys.stderr.flush()
                                break
 
-prompt_command = os.getenv("PROMPT_COMMAND", 'echo -ne "${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}"')
-default_xterm_title = commands.getoutput(prompt_command)
-del prompt_command
+default_xterm_title = None
 
 def xtermTitleReset():
+       global default_xterm_title
+       if default_xterm_title is None:
+               prompt_command = os.getenv('PROMPT_COMMAND')
+               if prompt_command is not None:
+                       default_xterm_title = commands.getoutput(prompt_command)
+               else:
+                       pwd = os.getenv('PWD','')
+                       home = os.getenv('HOME', '')
+                       if home != '' and pwd.startswith(home):
+                               pwd = '~' + pwd[len(home):]
+                       default_xterm_title = '%s@%s:%s' % (
+                               os.getenv('LOGNAME', ''), os.getenv('HOSTNAME', '').split('.', 1)[0], pwd)
        xtermTitle(default_xterm_title)
 
 def notitles():