Created
October 2, 2013 14:44
-
-
Save silviot/6794863 to your computer and use it in GitHub Desktop.
SublimeText import/export python script
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
#!/bin/env | |
""" | |
Import / export sublime config settings. | |
""" | |
import os | |
from subprocess import check_output | |
HOME_SUBL = os.path.expanduser("~/.config/sublime-text-3/Packages/User") | |
HOME_REV = os.path.abspath(os.path.join(os.path.dirname(__file__), | |
".config/sublime-text-3/Packages/User")) | |
assert os.path.exists(HOME_SUBL), HOME_SUBL | |
assert os.path.exists(HOME_REV), HOME_REV | |
def sh(cmd): | |
return check_output(cmd, shell=True) | |
# --- main API | |
def export(): | |
sh("cp -v {}/*-settings {}".format(HOME_SUBL, HOME_REV)) | |
def import_(): | |
sh("cp -v {}/*-settings {}".format(HOME_REV, HOME_SUBL)) | |
def add_alias(): | |
line = "alias gedit='subl'" | |
with open(os.path.expanduser("~/.bashrc"), "r+") as f: | |
content = f.read() | |
if line not in content: | |
f.seek(0) | |
f.write(content + "\n" + line + "\n") | |
# de-commend one of the followings | |
#export() | |
#import | |
#add_alias() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment