Last active
June 8, 2016 16:56
-
-
Save aviddiviner/c09217d2e8286561f4f193ccfab38b84 to your computer and use it in GitHub Desktop.
Smart hyperlinked stack traces in iTerm (open on correct line)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import re | |
import sys | |
from subprocess import call | |
if len(sys.argv) > 2: | |
filename, linenum = sys.argv[1], sys.argv[2] | |
if re.search(r'\.(py|rb|go|js)$', filename) and linenum: | |
if not str.isdigit(linenum): | |
parts = linenum.split(',') | |
if len(parts) > 1: | |
linenum = filter(str.isdigit, parts[1]) | |
if str.isdigit(linenum): | |
filename = '{0}:{1}'.format(filename, linenum) | |
call(['/usr/local/bin/subl', '--add', filename]) | |
else: | |
call(['/usr/bin/open', filename]) | |
# In iTerm, go to Profiles > Advanced > Semantic History > Run command... | |
# and set it to "/path/to/magic-iterm-open.py \1 \2 \4" (sans quotes) | |
# Also, make sure that Pointer > Cmd-Click Opens Filename/URL is enabled. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍