Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Easily switch between your two predefined themes for Sublime Text.
"name": "themeswitch",
"version": "0.0.1",
"description": "Easily switch between your two predefined themes for Sublime Text.",
"dependencies": {},
"devDependencies": {
"coffee-script": "^1.9.3",
"json-format": "0.0.1"
"author": "Fatih Acet <>"
fs = require 'fs'
formatter = require 'json-format'
PREF_FILE_PATH = '/Users/acetz/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings'
DARK : 'Packages/Dayle Rees Color Schemes/legacy/LastNight.tmTheme'
LIGHT : 'Packages/Dayle Rees Color Schemes/sublime/light/userscape.tmTheme'
DARK : 'Spacegray.sublime-theme'
LIGHT : 'Spacegray Light.sublime-theme'
prefFile = fs.readFileSync PREF_FILE_PATH
prefJson = JSON.parse prefFile
{ color_scheme, theme } = prefJson
newScheme = if color_scheme is SCHEMES.DARK then SCHEMES.LIGHT else SCHEMES.DARK
newTheme = if theme is THEMES.DARK then THEMES.LIGHT else THEMES.DARK
prefJson.color_scheme = newScheme
prefJson.theme = newTheme
fs.writeFileSync PREF_FILE_PATH, formatter prefJson, 'utf-8'
catch e
console.log e
console.log 'Failed to fetch and parse Sublime Preferences file.'

This comment has been minimized.

Copy link
Owner Author

@fatihacet fatihacet commented Oct 13, 2015

alias switch-sublime-theme="cd ~/Development/themeswitch ; coffee -n; cd -"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment