Rev 738: Allow setting the title in a cygwin terminal. in http://bzr.arbash-meinel.com/plugins/bzrtools
John Arbash Meinel
john at arbash-meinel.com
Thu Dec 17 21:15:06 GMT 2009
At http://bzr.arbash-meinel.com/plugins/bzrtools
------------------------------------------------------------
revno: 738
revision-id: john at arbash-meinel.com-20091217211446-oc7k5u8jq4tw18hl
parent: aaron at aaronbentley.com-20091201032457-ng4w9ssd2uavdf3c
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: bzrtools
timestamp: Thu 2009-12-17 15:14:46 -0600
message:
Allow setting the title in a cygwin terminal.
Even if we are running native python, we can still call out to cygwin.
And we know that is safe, because otherwise we wouldn't have TERM set.
-------------- next part --------------
=== modified file 'shell.py'
--- a/shell.py 2009-11-16 20:47:28 +0000
+++ b/shell.py 2009-12-17 21:14:46 +0000
@@ -137,14 +137,21 @@
self.prompt = "bzr%s> " % prompt
def set_title(self, command=None):
- try:
- b = Branch.open_containing('.')[0]
- version = "%s:%d" % (b.nick, b.revno())
- except:
+ if self.tree is not None:
+ version = "%s:%d" % (self.tree.branch.nick,
+ self.tree.branch.revno())
+ else:
version = "[no version]"
if command is None:
command = ""
- sys.stdout.write(terminal.term_title("bzr %s %s" % (command, version)))
+ if sys.platform == 'win32' and os.environ.get('TERM', '') == 'cygwin':
+ # if we are running Win32 python, but we are running under a cygwin
+ # shell, we can spawn 'sh.exe' and get it to set our title for us
+ # Just writing to stdout is not enough
+ os.system('sh -c "echo -ne \'\033]0;bzr shell %s %s\007\'"'
+ % (command, version))
+ else:
+ sys.stdout.write(terminal.term_title("bzr %s %s" % (command, version)))
def do_cd(self, line):
if line == "":
More information about the bazaar-commits
mailing list