Skip to content

Instantly share code, notes, and snippets.

@fatihacet
Created June 1, 2015 14:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fatihacet/7c63b9de40cc4c88bca2 to your computer and use it in GitHub Desktop.
Save fatihacet/7c63b9de40cc4c88bca2 to your computer and use it in GitHub Desktop.
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 <fatih@fatihacet.com>"
}
fs = require 'fs'
formatter = require 'json-format'
PREF_FILE_PATH = '/Users/acetz/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings'
SCHEMES =
DARK : 'Packages/Dayle Rees Color Schemes/legacy/LastNight.tmTheme'
LIGHT : 'Packages/Dayle Rees Color Schemes/sublime/light/userscape.tmTheme'
THEMES =
DARK : 'Spacegray.sublime-theme'
LIGHT : 'Spacegray Light.sublime-theme'
prefFile = fs.readFileSync PREF_FILE_PATH
try
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.'
@fatihacet
Copy link
Author

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

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