From 0431cbe6959ed4a27cc676ae81ca0b64932b5be5 Mon Sep 17 00:00:00 2001 From: Sergey Ryabov Date: Tue, 1 Nov 2016 00:55:20 +0300 Subject: [PATCH] Set terminal title to current device/emulator name. --- pidcat.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pidcat.py b/pidcat.py index 826ad15..ce1cebf 100755 --- a/pidcat.py +++ b/pidcat.py @@ -175,6 +175,16 @@ def allocate_color(tag): BUG_LINE = re.compile(r'.*nativeGetEnabledTags.*') BACKTRACE_LINE = re.compile(r'^#(.*?)pc\s(.*?)$') +def set_term_title(title): + sys.stdout.write("\033]0;%s\a" % title) + +def clear_term_title(): + set_term_title("") + +device_name_command = base_adb_command + ["shell", "getprop", "ro.product.model"] +device_name = subprocess.Popen(device_name_command, stdout=PIPE, stderr=PIPE).communicate()[0] +set_term_title(device_name) + adb_command = base_adb_command[:] adb_command.append('logcat') adb_command.extend(['-v', 'brief']) @@ -358,3 +368,5 @@ def tag_in_tags_regex(tag, tags): linebuf += indent_wrap(message) print(linebuf.encode('utf-8')) + +clear_term_title()