Skip to content

Commit c598bb3

Browse files
committed
The stacktrace is copied to the tmux paste buffer if running inside tmux
1 parent 4370963 commit c598bb3

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

autoload/vebugger/lldb_wrapper.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import re
1414
import subprocess
1515
import sys
16+
import tempfile
1617

1718

1819
FilePosition = collections.namedtuple('FilePosition', ['filepath', 'linenumber'])
@@ -146,21 +147,24 @@ def clear(arguments):
146147

147148
def _copy_stacktrace_to_clipboard(self, stacktrace):
148149
stacktrace_text = '\n'.join('File "{}", line {:d},'.format(file, line) for file, line in reversed(stacktrace))
149-
platform_system = platform.system()
150150
process = None
151-
if platform_system == 'Darwin':
152-
process = subprocess.Popen('pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE)
151+
if 'TMUX' in os.environ:
152+
process = subprocess.Popen(['tmux', 'load-buffer', '-'], stdin=subprocess.PIPE)
153153
else:
154-
# assume we are running on Linux
155-
for cmd in (['xclip', '-selection', 'clipboard'], ['xsel', '--clipboard']):
156-
try:
157-
process = subprocess.Popen(cmd, stdin=subprocess.PIPE)
158-
break
159-
except OSError:
160-
pass
154+
platform_system = platform.system()
155+
if platform_system == 'Darwin':
156+
process = subprocess.Popen('pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE)
161157
else:
162-
print(prefix_output('Stacktrace cannot be copied to clipboard! Either install xclip or xsel.',
163-
'warning: '))
158+
# assume we are running on Linux
159+
for cmd in (['xclip', '-selection', 'clipboard'], ['xsel', '--clipboard']):
160+
try:
161+
process = subprocess.Popen(cmd, stdin=subprocess.PIPE)
162+
break
163+
except OSError:
164+
pass
165+
else:
166+
print(prefix_output('Stacktrace cannot be copied to clipboard! Either install xclip or xsel.',
167+
'warning: '))
164168
if process is not None:
165169
process.communicate(stacktrace_text.encode('utf-8'))
166170

0 commit comments

Comments
 (0)