Sublime Forum

Storing User Settings Elsewhere

#1

Is it possible to change the user settings directory to be somewhere other than the default location?

I like to keep my settings checked into git (mainly so that I can easily work/migrate between machines) and would love to be able to have ST2 settings be loaded from ~/etc/sublime2/… or similar.

I suspect the answer is its not possible right now :frowning:

0 Likes

#2

I guess you can just make a symlink or something similar?

1 Like

#3

I did a funky setup. I installed ST2 then put the portable version in my Dropbox. Then I deleted the contents of my Program Files\ST2 directory and linked the portable version to that folder (directory junction I think it’s called in Windows). This gives me my context menu entry on right click but allows me to sync my settings with dropbox. If I wanted to, I could turn that folder into a git repo. I then did the same steps at the office… voila, synced settings. Even synced tabs which is awesome… and even more awesome is syncing unsaved tabs. I can create a new text document, put some text in there, drive to work and have that tab waiting for me. Pretty cool! :smile:

One thing I was hoping to be able to do was to create a machine specific config file. At work I use the light Soda theme since I have crazy glaring lights and the dark themes are just too much contrast. At home I switch back to the dark theme. It’s easy to change, but if I could setup a machine_name_01.sublime-settings for each desktop, I’d be in heaven! :smile:

0 Likes

#4

Hey, thought your problem was kind of interesting because I work on three different machines during the day (Mac OS X at work, Windows & Ubuntu at home.) I just keep my packages directory synced across them all using Dropbox and some symlinks.

Anyways, this should do what you want.

import sublime, sublime_plugin
import platform

class SodaThemeColorByHostCommand(sublime_plugin.WindowCommand):
	dark_theme = 'Soda Dark.sublime-theme'
	light_theme = 'Soda Light.sublime-theme'

	dark_machines = '']
	light_machines = '']

	def run(self):
		s = sublime.load_settings('Global.sublime-settings')
		hostname = platform.node()
		if hostname in self.light_machines:
			s.set('theme', self.light_theme)
		elif hostname in self.dark_machines:
			s.set('theme', self.dark_theme)
		sublime.save_settings('Global.sublime-settings')

sublime.active_window().run_command('soda_theme_color_by_host')

You should just be able to throw that into your Packages in a python file (I have it as ‘sodacolor.py’) and fill in the hostnames of the machines you want to be dark/light.

0 Likes

#5

Awesome, thanks for the code! It looks like it should work perfectly, but I’m getting an error… unfortunately, I’m a complete Python noob, so I’m not sure if this is a Sublime thing or a Python thing… here’s the error:

Reloading plugin D:\MyStuff\Dropbox\Software\Sublime Text 2\Data\Packages\sodacolor.py Traceback (most recent call last): File ".\sublime_plugin.py", line 57, in reload_plugin File ".\sodacolor.py", line 20, in <module> sublime.active_window().run_command('soda_theme_color_by_host') AttributeError: 'NoneType' object has no attribute 'run_command'
Also note that I’m running build 2101. I’m hoping this error doesn’t stem from the fact that I’m keeping the app in my Dropbox folder. Any ideas?

Thanks a bunch!

1 Like

#6

Nope, nothing to do with you keeping your installation in Dropbox. Unfortunately when sodacolor.py is sourced, there are no windows, so that’s why you see “‘NoneType’ object has no attribute ‘run_command’.” I’m working on a complete overhaul of this, and while there doesn’t seem to be a way to get it to run on start up, you should at least be able to hit a single key binding and get the theme you wanted.

0 Likes

#7

Yup, “working on something” became “keeping me up way too late.” Here’s what you need Sean:
https://forum.sublimetext.com/t/host-specific-settings/2256/1

Follow my instructions in there, then you’ll want something like:

{
	"machine1": {
		"defined": {
			"global": "theme"]
		},
		"theme": "Soda Dark.sublime-theme",
	},
	"machine2": {
		"defined": {
			"global": "theme"]
		},
		"theme": "Soda Light.sublime-theme",
	}
}

in User/Hosts.sublime-settings, with the machine names set to whatever you use. Ctrl+Shift+H when you start using Sublime and you should be good to go.

0 Likes

#8

Haha, thanks for staying up late. Funny how time flies when you’re working on something fun. :smile:

Thanks for the help, this works perfectly!

0 Likes