Sublime Forum

[Sublime Merge]Hope for multi-user feature


it will be very useful to switch different git account by a simple combo box, no editing again and again.


Change Github Account
How do I add a second user?

The easiest way to do this currently is by using this method outlined by @OdatNurd: Execute external tool from SublimeMerge. I actually do something like this to swtich between my personal and work .gitconfig. Thought you could make one more complex if needed.

Basically, I have a script that scans the current .gitconfig and looks at the to know what config is loaded. I have two backed up configs: .gitconfig-personal, .gitconfig-work. In this simple case, the script scans the current .gitconfig for the user name and copies the current info to it’s respective backup location and copies content from the other backed up profile to the current .gitconfig.

Then I simply create an alias as @OdatNurd outlined in his post and create a command in Default.sublime-commands. Then I can just run the command from the command palette and then press ctrl + r to reload/refresh the profile in Merge.

Maybe this will give some ideas or help.

1 Like


Here is the script I use for my simple case:

"""Switch git profiles."""
import os
import re

RE_USER = re.compile(r'^\s*name\s*=\s*(.*)$', re.M)
WORK_NAME = "Name"

path = os.path.expanduser('~/.gitconfig')
if os.path.exists(path):
    with open(path, 'r') as f:
        buf =

    m =
    if m:
        print('USER: ',
        user =
        if user == WORK_NAME:
            msg = 'Switching to personal...'
            switch = path + '-personal'
            msg = 'Switching to work...'
            switch = path + '-work'
        if os.path.exists(switch):
            with open(switch, 'r') as f:
                buf =
            with open(path, 'w') as f:

Then I create a simple git alias in all the configs I have saved away:

	switchProfile = "!f() { /usr/local/bin/git-switch; }; f"

Then I create a simple command in Default.sublime-commands in Merge’s Packages/User folder:

		"caption": "Switch Profile",
		"command": "git", "args": {
			"argv": ["switchProfile"]

For me this takes the pain out of switching users. I guess you could allow the script to take a user name and create multiple commands that switches to a specific user, but I only need to switch between two.