Skip to content

Instantly share code, notes, and snippets.

@alecthomas
Created March 31, 2016 01:48
Show Gist options
  • Save alecthomas/21cf0cc7e5e2a0f93d9b6401981cb1c6 to your computer and use it in GitHub Desktop.
Save alecthomas/21cf0cc7e5e2a0f93d9b6401981cb1c6 to your computer and use it in GitHub Desktop.
Sublime plugin to toggle between light and dark themes
import sublime
import sublime_plugin
class DayAndNightCommand(sublime_plugin.ApplicationCommand):
def run(self):
s = sublime.load_settings("Preferences.sublime-settings")
if s.get("theme") == "Reverse Gravity.sublime-theme":
print("Switching to dark theme")
s.set("theme", "Gravity.sublime-theme")
s.set("color_scheme", "Packages/User/SublimeLinter/SwapOff (SL).tmTheme")
else:
print("Switching to light theme")
s.set("theme", "Reverse Gravity.sublime-theme")
s.set("color_scheme", "Packages/User/Espresso Soda (Custom).tmTheme")
sublime.save_settings("Preferences.sublime-settings")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment