visual-studio-codersyncvscode-extensionsremote-server

Run rsync on every save in VSCode


I have a repository on my local system and am testing my changes on a remote server. I am using VSCode for development. I want that on every save, rsync should run in background and sync the changes in the current local file with remote. How can I achieve this with VSCode?


Solution

  • I am using Save and Run vscode extension for syncing code between local and remote server whenever I hit save in VSCode. Following is the configuration I am using.

    "saveAndRun": {
      "commands": [
        {
          "match": ".*",
          "cmd": "rsync -av --no-owner ${file} {destination folder}${relativeFile}",
          "useShortcut": false,
          "silent": false
        },
      ]
    }
    

    The output generated when the rsync command is run can been seen in VSCode terminal. You can add the above configuration in .vscode/settings.json file. You can learn more about editing settings.json file here