-
-
Save roryrjb/3686848f7a612c71e4c3f4fa6f60c39c to your computer and use it in GitHub Desktop.
Sublime Text wrapper for use within WSL1
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/env python3 | |
import sys | |
import subprocess | |
import os | |
filename = os.path.abspath(sys.argv[1]) | |
if filename.startswith('/mnt'): | |
# /mnt/c/a/b/c.txt -> c:\a\b\c.txt | |
parts = filename.split('/') | |
parts[2] += ':' | |
path = '\\'.join(parts[2:]) | |
else: | |
# /a/b/c.txt -> \\wsl.localhost\Ubuntu\a\b\c.txt | |
path = '\\\\wsl.localhost\\Ubuntu\\' + filename.replace('/', '\\') | |
subprocess.run(['subl.exe', '-w', path]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
subl
(changing any hardcoded assumptions I have made) and make executable, then put it in your$PATH
subl.exe
is in your$PATH
(e.g.PATH=/mnt/c/Program Files/Sublime Text:$PATH
)subl
your$EDITOR