Skip to content

Instantly share code, notes, and snippets.

@ebrensi
Last active December 21, 2023 07:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ebrensi/5209ff45ed094c83cfbb0a14288c982c to your computer and use it in GitHub Desktop.
Save ebrensi/5209ff45ed094c83cfbb0a14288c982c to your computer and use it in GitHub Desktop.
Sublime Text 3 plugin to select a color scheme for the current tab only

Installation

Put change_tab_color_scheme.py in the folder that opens up when you select Preferences > Browse Packages...

Now you have a command called change_tab_color_scheme that you can access from the command window. You can set a key binding by going to Preferences > Key Bindings

I personally like the "ctrl+k", "ctrl+c" sequence. In the {blah}.sublime-keymap file, add the key binding like this...

[
	{
	    "keys": ["ctrl+k", "ctrl+c"],
	    "command": "change_tab_color_scheme"
	}
]

Now you can quickly set the color scheme to whatever you want in each tab.

These color changes are not persisistent as far as I know.

import sublime
import sublime_plugin
import os
class ChangeTabColorScheme(sublime_plugin.WindowCommand):
def run(self):
window = sublime.active_window()
view = window.active_view()
settings = view.settings()
current_scheme = settings.get('color_scheme', '')
themes = self.installed_themes()
names = sorted(themes)
def make_selection(index):
name = names[index]
fname = themes[name]
settings.set("color_scheme", fname)
def on_done(index):
if index == -1:
settings.set("color_scheme", current_scheme)
return
make_selection(index)
window.show_quick_panel(
names,
on_done,
on_highlight=make_selection
)
def installed_themes(self):
scheme_paths = sublime.find_resources('*.tmTheme')
scheme_paths.extend(
sublime.find_resources('*.sublime-color-scheme')
)
themes = {os.path.basename(path).split(".")[0]: path for path in scheme_paths}
return themes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment