diff options
-rw-r--r-- | pym/output.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/pym/output.py b/pym/output.py index ff40325b0..4ff7ce5f7 100644 --- a/pym/output.py +++ b/pym/output.py @@ -173,13 +173,15 @@ def nc_len(mystr): tmp = re.sub(esc_seq + "^m]+m", "", mystr); return len(tmp) -def xtermTitle(mystr): +def xtermTitle(mystr, raw=False): if havecolor and dotitles and os.environ.has_key("TERM") and sys.stderr.isatty(): myt=os.environ["TERM"] legal_terms = ["xterm","Eterm","aterm","rxvt","screen","kterm","rxvt-unicode","gnome"] for term in legal_terms: if myt.startswith(term): - sys.stderr.write("\x1b]0;"+str(mystr)+"\x07") + if not raw: + mystr = "\x1b]0;%s\x07" % mystr + sys.stderr.write(mystr) sys.stderr.flush() break @@ -198,9 +200,9 @@ def xtermTitleReset(): home = os.getenv('HOME', '') if home != '' and pwd.startswith(home): pwd = '~' + pwd[len(home):] - default_xterm_title = '%s@%s:%s' % ( + default_xterm_title = '\x1b]0;%s@%s:%s\x07' % ( os.getenv('LOGNAME', ''), os.getenv('HOSTNAME', '').split('.', 1)[0], pwd) - xtermTitle(default_xterm_title) + xtermTitle(default_xterm_title, raw=True) def notitles(): "turn off title setting" |