Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store Sublime Text preferences in Github

I have a few different machines I use throughout the day, and I use git to pull down the most recent code on my projects.

However, my Sublime Text installs are different on each machine, and I can't keep my packages straight. My Sublime Text 3 preferences/packages are stored in ~/Library/Application Support/Sublime Text 3.

Is there a way to store my preferences in Github so I can pull them down on other machines? I'm nervous about doing this and am wondering if anybody else has done this before.

like image 649
Johnathan Elmore Avatar asked Aug 02 '16 00:08

Johnathan Elmore


1 Answers

Store Package Control/User

You only need to add the ~/Library/Application Support/Sublime Text 3/Package Control/User/ (or on Windows: C:\Users\{username}\AppData\Roaming\Sublime Text 3\Packages\User) directory.

From https://packagecontrol.io/docs/syncing

The proper solution is to install Package Control on all machines and then to sync only the Packages/User/ folder. This folder contains the Package Control.sublime-settings file, which includes a list of all installed packages. If this file is copied to another machine, the next time Sublime Text is started, Package Control will install the correct version of any missing packages.

Steps to set it up

Create a new repo on github, name it something like "sublime-prefs", then run these commands:

cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/User
git init
git add Package\ Control.sublime-settings
git commit -am "settings from from <device name>"
git remote add origin https://github.com/<github name>/<repo name>.git
git push -u origin master

Pulling down to other machines...

Quit Sublime Text 3, then run these commands (using answer from How do I clone into a non-empty directory?):

cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/User/
git init
git remote add origin https://github.com/<github name>/<repo name>.git
rm Package\ Control.sublime-settings
git fetch
git checkout -t origin/master
like image 198
Johnathan Elmore Avatar answered Sep 30 '22 18:09

Johnathan Elmore