randy3k / RemoteSubl

Use rmate with Sublime Text, an improved fork of rsub.
327 stars 20 forks source link

Feature enhancement request: Change color scheme depending on host? #2

Open TMorville opened 6 years ago

TMorville commented 6 years ago

I often have 2-3 different sessions with Sublime + iTerm2 open. Using a simple batch script, I have set my iTerm2 to change colours (by activating a different iTerm user) when I ssh into a different host.

I was wondering if the same could be done for RemoteSubl? Such that when I open something from a specific host/ip/port, then Sublime opens in a different colour scheme, depending on the host/ip/port.

randy3k commented 6 years ago

You should be able to write a simple plugin to change color scheme based on view.settings().get('remote_subl.host')

TMorville commented 6 years ago

This minimal implementation works. Any suggestions on how to run the plug-in every time I open something with remote_subl?

import sublime_plugin

class ExampleCommand(sublime_plugin.TextCommand):

    def run(self, view):
        view = self.view
        host = view.settings().get('remote_subl.host', None)

        print(host)

        if host:

            view.settings().set(
                'color_scheme',
                'Packages/Color Scheme - Default/Mariana.tmTheme')

            print(view.settings().get('color_scheme'))

        if host is None:

            view.settings().set(
                'color_scheme',
                'Packages/Color Scheme - Default/Monokai.tmTheme')

            print(view.settings().get('color_scheme'))
randy3k commented 6 years ago

You could use an EventListener to tell Sublime to apply a different color scheme when remote_subl.host is present.

Phidica commented 2 years ago

Hi @randy3k, would you accept a PR to incorporate this functionality directly into RemoteSubl?