Forked from jasonlong/Default (OSX).sublime-keymap
Last active
March 4, 2024 19:14
-
-
Save rbf/195acdfe8f51b65e5ecd to your computer and use it in GitHub Desktop.
A simple way to toggle between dark and light themes in Sublime Text 2 and 3.
This file contains hidden or 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
// Copy this to your keybindings (Preferences > Key Bindings - User) | |
// Change the keybinding, color schemes, and themes to your preferences | |
{ | |
"keys": ["ctrl+shift+s"], "command": "toggle_color_scheme", | |
"args": { | |
"light_color_scheme": "Packages/Solarized Color Scheme/Solarized (light).sublime-color-scheme", | |
"dark_color_scheme": "Packages/Solarized Color Scheme/Solarized (dark).sublime-color-scheme", | |
"light_theme": "Adaptive.sublime-theme", | |
"dark_theme": "Adaptive.sublime-theme" | |
} | |
} |
This file contains hidden or 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
# From https://gist.github.com/rbf/195acdfe8f51b65e5ecd | |
# Forked from https://gist.github.com/jasonlong/5395357 | |
# Install with: | |
# curl -#SL https://gist.github.com/rbf/195acdfe8f51b65e5ecd/raw/ToggleColorSchemeCommand.py -o ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/User/ToggleColorSchemeCommand.py | |
# // Copy this to your keybindings (Preferences > Key Bindings - User) | |
# // Change the keybinding, color schemes, and themes to your preferences | |
# | |
# { | |
# "keys": ["ctrl+shift+s"], "command": "toggle_color_scheme", | |
# "args": { | |
# "light_color_scheme": "Packages/Solarized Color Scheme/Solarized (light).sublime-color-scheme", | |
# "dark_color_scheme": "Packages/Solarized Color Scheme/Solarized (dark).sublime-color-scheme", | |
# "light_theme": "Adaptive.sublime-theme", | |
# "dark_theme": "Adaptive.sublime-theme" | |
# } | |
# } | |
import sublime, sublime_plugin | |
class ToggleColorSchemeCommand(sublime_plugin.TextCommand): | |
def run(self, edit, **args): | |
light_color_scheme = args["light_color_scheme"] | |
dark_color_scheme = args["dark_color_scheme"] | |
light_theme = args["light_theme"] | |
dark_theme = args["dark_theme"] | |
settings = sublime.load_settings('Preferences.sublime-settings') | |
current_color_scheme = settings.get('color_scheme') | |
if current_color_scheme == light_color_scheme: | |
settings.set('color_scheme', dark_color_scheme) | |
settings.set('theme', dark_theme) | |
else: | |
settings.set('color_scheme', light_color_scheme) | |
settings.set('theme', light_theme) | |
sublime.save_settings('Preferences.sublime-settings') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That is very helpful, thank you!