zokugun / vscode-sync-settings

Easily synchronize your settings
MIT License
146 stars 12 forks source link
sync synchronization vscode vscode-extension

Sync Settings

License Visual Studio Marketplace Version Open VSX Version Ko-fi Liberapay Paypal

With Sync Settings, you can synchronize your settings/resources across multiple devices.
You can also switch between profiles with their own settings/resources.

HowTo

  1. configure the repository:

    > Sync Settings: Open the repository settings

  2. upload your settings to the repository:

    > Sync Settings: Upload (user -> repository)

  3. download your settings into a new editor:

    > Sync Settings: Download (repository -> user)

Configuration

Repository

The repository is configured with the following file:

settings.yml
# current machine's name, optional; it can be used to filter settings or in the commit message
hostname: ""
# more details at https://github.com/zokugun/vscode-sync-settings/blob/master/docs/hostname.md

# selected profile, required
profile: main
# repository to sync the settings with, required
repository:
  # repository's type, required (dummy: no sync)
  type: dummy

You can open that file with the command:

> Sync Settings: Open the repository settings

Repository types

file

# sync on local file system
repository:
  type: file
  # path of the local directory to sync with, required
  path: ~/Development/settings

local git

# sync on local git
repository:
  type: git
  # path of the local git repository to sync with, required
  path: ~/Development/settings
  # branch to sync on, optional (set to `master` by default)
  branch: master

If not initialized, the git repository will be automatically initialized.

How to personalize the commit messages

remote git

# sync on remote git
repository:
  type: git
  # url of the remote git repository to sync with, required
  url: git@github.com:username/settings.git
  # branch to sync on, optional (set to `master` by default)
  branch: master

No authentifications are stored.
But the git command on your system will need to be able to read/write on the remote repository.

How to personalize the commit messages

rsync

# sync on remote directory with rsync
repository:
  type: rsync
  # url of the remote directory to sync with, required
  url: server:~/settings
  # shell used by rsync, optional (set to `ssh` by default)
  shell: ssh

The access to the server shouldn't require the need of any passwords.

webdav

# sync on remote directory with webdav
repository:
  type: webdav
  # url of the remote directory, required
  url: http://localhost:9988/webdav/server
  # the username, optional
  username: webdav-user
  # the password, optional
  password: pa$$w0rd!
  # all options available at https://github.com/zokugun/vscode-sync-settings/blob/master/docs/webdav.md

All WebDAV options available here

Which resources?

You can configure what and how to synchronize with properties in your regular settings (settings.json).

External Files

Additionally, you can sync external files with the following property in your regular settings (settings.json):

"syncSettings.additionalFiles": [
    "~globalStorage/alefragnani.project-manager/projects.json",
    "~/vscode_projects.json",
]

The paths can start with special prefixes:

settings.yml

When trying the synchronize the settings.yml of the extension, an error will be thrown.

There is no need to synchronize that file since it contains only the needed and required informations to effectuate a synchronization, from the first one to the last.

Saved Extensions

When installing an extension, if a matching .vsix is present in the data/extensions directory of the profile, that .vsix will installed instead of the one found in the marketplace.

You can find the data/extensions directory by executing the command > Sync Settings: Reveal the profile in the file explorer.

Profiles

Each profile has its own directory in the repository and can be configured independently of each other.

You can create a new profile with the command > Sync Settings: Create a new profile.
Or switch to an existing one with the command > Sync Settings: Switch to profile.

Profile Inheritance

A profile can extend an existing profile but it's limited to the following resources:

You can select the profile to extend from when creating a new profile (command > Sync Settings: Create a new profile).
The command > Sync Settings: Open the profile settings will allow you to modify the property extends.

Commands

JSONC Attributes

JSONC attributes can be used to enable/disable settings based on, for example, the OS or the editor's version.

example

{
    // #if(os="mac")
    // "editor.fontWeight": "300",
    // #elif(os="windows")
    // "editor.fontWeight": "400",
    // #else
    // "editor.fontWeight": "500",
    // #endif
}

When the settings.json is downloaded, depending on the OS, the setting editor.fontWeight will have the following value:

OS editor.fontWeight
Linux 500
MacOS 300
Windows 400

More details here

Hooks

Hooks allow you to run commands in an integrated terminal before and after the following events:

More details here

Crons

syncSettings.crons allows you to schedule the commands download, review or upload.

"syncSettings.crons": {
    "review": "0 * * * *",      // every hour
    "download": "0 9 * * *",    // at 9AM, every day
    "upload": "0 17 * * *"      // at 5PM, every day
}

Remote

Remote mode is supported but the synchronization will be limited to only extensions.

More details here

Donations

Support this project by becoming a financial contributor.

Ko-fi ko-fi.com/daiyam
Liberapay liberapay.com/daiyam/donate
PayPal paypal.me/daiyam99

Enjoy!