diff options
author | Zac Medico <zmedico@gentoo.org> | 2006-02-21 01:16:56 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2006-02-21 01:16:56 +0000 |
commit | 167b019857ae385ae1e2a366b15ed49f84b0a3c6 (patch) | |
tree | e5f844580223bec8547d921d0c9b0ef759c8184c | |
parent | 38f7cc229561dfd22aaa8de8ea705640270f2f68 (diff) | |
download | portage-167b019857ae385ae1e2a366b15ed49f84b0a3c6.tar.gz portage-167b019857ae385ae1e2a366b15ed49f84b0a3c6.tar.bz2 portage-167b019857ae385ae1e2a366b15ed49f84b0a3c6.zip |
Patch by marienz to generate default_xterm_title just in time with python instead of the shell. Fixes "Bad substitution" shell messages reported by flameeyes.
svn path=/main/trunk/; revision=2755
-rw-r--r-- | pym/output.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/pym/output.py b/pym/output.py index ac57fe366..e361e063d 100644 --- a/pym/output.py +++ b/pym/output.py @@ -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(): |