Skip to content

Instantly share code, notes, and snippets.

@timurkhafizov
Last active December 26, 2015 23:09
Show Gist options
  • Save timurkhafizov/7228084 to your computer and use it in GitHub Desktop.
Save timurkhafizov/7228084 to your computer and use it in GitHub Desktop.
# Can be accessed via Preferences > Key Bindings - User
[
{
"keys": ["super+shift+o"], "command": "toggle_color_scheme",
"args":
{
"color_scheme_1": "Packages/Solarized Color Scheme/Solarized (dark).tmTheme",
"color_scheme_2": "Packages/Solarized Color Scheme/Solarized (light).tmTheme",
"theme1": "Sodarized Dark 3.sublime-theme",
"theme2": "Sodarized Light 3.sublime-theme"
}
}
]
# Create new plugin via Tools > New Plugin...
import sublime, sublime_plugin
class ToggleColorSchemeCommand(sublime_plugin.TextCommand):
def run(self, edit, **args):
scheme1, scheme2 = args["color_scheme_1"], args["color_scheme_2"]
theme1, theme2 = args["theme1"], args["theme2"]
settings = sublime.load_settings('Preferences.sublime-settings')
current_scheme = settings.get("color_scheme")
current_theme = settings.get("theme")
new_scheme = scheme1 if current_scheme == scheme2 else scheme2
new_theme = theme1 if current_theme == theme2 else theme2
settings.set("color_scheme", new_scheme)
settings.set("theme", new_theme)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment