Unescaping strings of stack traces

I often find myself copying strings of Java stack traces which have escaped tabs and newlines (\t\n). Those aren’t fun to read. Here’s a quick Python script I rigged up to grab what’s on the clipboard and format it properly. I call it unescape:

#!/usr/bin/env python3
'''

Grab the string on the clipboard and print it to standard out,
interpreting tabs and newlines appropriately

'''
import subprocess
r = subprocess.run(["/usr/bin/pbpaste"], capture_output=True, encoding="unicode_escape")
print(r.stdout)

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s