Sublime Forum

Host Specific Settings

#1

What Do?

Lets you to define a Hosts.sublime-settings file with specific settings for each machine you work on.

Backstory

Hello everyone. I was lurking the forums the other night, (thus why I only have three posts,) and read “Storing User Settings Elsewhere” in General Discussion. SeanWcom mentioned he was using the portable version of Sublime stored in Dropbox, and since he uses it both at work and at home, wanted to quick switch which Soda theme color he was using.

Between work and home, I use three different machines almost everyday, and none of them have the same OS. So to remain sane, I sync configuration/dot files between them all using Dropbox, and I’m doing the same for Sublime, as I suspect quite a few are. Anyways, when I read Sean’s post, I thought, “Geez, I could write that,” and so I did, and it did not work properly.

Anyways, to make up for that failure, here’s something that should work.

Using

Really all you need to worry about is defining a Hosts.sublime-settings file in your User directory. It’s pretty straight forward, so it’ll be easiest just to show you.

{
	"machine_name1" {
		"defined": {
			"global": "global_setting1", "global_setting2"],
			"file": "file_setting1"]
		},
		"global_setting1": true,
		"global_setting2": 150,
		"file_setting1": "sasquatch"
	},
	"machine_name2": {
		etc...
	}
}

The nastiest part about this is the “defined” property. Sublime’s Setting class isn’t iterable at the moment, so to get around it you have to tell Hosts what to set, and where those settings belong. Right now you can configure any of the settings that would appear in “Base File.sublime-settings” (aka File Settings - User in Preferences) or “Global.sublime-settings” (Global Settings - User). Those are under the ‘file’ and ‘global’ properties respectively.

To activate your Host specific settings, just hit Ctrl+Shift+H on Windows and Linux, or Cmd+Shift+H on Mac. You can also activate them in the Preferences menu.

Anyways, thanks to Jon for creating an editor with a plugin system that let me easily create this weirdness, and thanks to wbond for writing great plugins, whose configuration files I then stole and tweaked to make this in a matter of hours. Eventually I’ll get this up on GitHub so you can install it using Package Control, which is awesome, but for the moment it’s nearly 3am, and I need to rest. Hope you find some use for it.

Edit: Naturally, I didn’t attach the package. Worse, I didn’t check if I could upload sublime-packages to the forum first. Link in a moment.

Edit: http://www.mediafire.com/?wuala4cjq8chh4c

0 Likes

Storing User Settings Elsewhere
#2

This is so awesome… thanks so much! Works like a champ!

0 Likes

#3

Does this still work in ST3? I’m trying to use it to increase font size on a hi-dpi display.

{
	"SurfacePro-Sea": {
		"defined": {
			"global": "font_size"]
		},
		"font_size": 16
	}
}

This doesn’t seem to have any effect.

I see the “use host settings” menu item, but when I choose it, nothing changes, and it doesn’t get checked. So maybe this isn’t supported in ST3…

0 Likes