From 6d329b130abd40cafe1af7da6e4f51c9fc7d8aaf Mon Sep 17 00:00:00 2001 From: kelianchun Date: Thu, 24 Mar 2016 13:02:02 +0800 Subject: [PATCH] remove ps1 search remove ps1 search --- connect.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/connect.py b/connect.py index 4c7989614..c3d575249 100755 --- a/connect.py +++ b/connect.py @@ -303,6 +303,7 @@ class SshTty(Tty): data = '' input_str = '' input_mode = False + vim_end_flag = False try: tty.setraw(sys.stdin.fileno()) tty.setcbreak(sys.stdin.fileno()) @@ -363,12 +364,13 @@ class SshTty(Tty): if input_str != x: data += input_str if self.vim_flag: - match = self.ps1_pattern.search(self.vim_data) + match = re.compile(r'\x1b\[\?1049', re.X).findall(self.vim_data) if match: - self.vim_flag = False - data = self.deal_command(data)[0:200] - if len(data) > 0: - TtyLog(log=log, datetime=datetime.datetime.now(), cmd=data).save() + if vim_end_flag or len(match) == 2: + self.vim_flag = False + vim_end_flag = False + else: + vim_end_flag = True else: data = self.deal_command(data)[0:200] if len(data) > 0: