Skip to content

Instantly share code, notes, and snippets.

@Qwaz
Created April 4, 2021 07:20
Show Gist options
  • Save Qwaz/fda845df4cc6ba3c64fe3960315f1b29 to your computer and use it in GitHub Desktop.
Save Qwaz/fda845df4cc6ba3c64fe3960315f1b29 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# Set in SumatraPDF
# wsl /home/qwaz/open-in-wsl.py "%f:%l"
# Original path:
# \wsl$\Ubuntu\home\qwaz\tex\p.tex:123
# Modified path:
# /home/qwaz/tex/p.tex:123
import os
import subprocess
import sys
location = sys.argv[1]
splitted = location.split("\\")
wsl_index = splitted.index("wsl$")
location = "/" + "/".join(splitted[wsl_index + 2:])
subprocess.run(["code", "-r", "-g", location])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment