Home > Software design >  How do I change my VScode settings to not sync specific commands?
How do I change my VScode settings to not sync specific commands?

Time:11-08

I am using VScode on both my Macbook and my PC and my settings are synced. I use coderunner to run my python programs. My problem is that in my settings.json, the command I use to run my program on my mac is different to the one I need to use on my PC. The specific command I use is clear && python3 -u. Since Vscode runs my code through the terminal, I have it clear every time I run it. When I am on my PC instead of my Mac, the command does not work. I do not want to have to change the command in the settings every time I switch beween computers. This is what the settings look like.

enter image description here

I did try switching it at first to just py in my PC settings, since that is the command that the PC command prompt needs to activate python. But even that gave me an error and it changed the settings on my macbook. Is there something in the settings I can add or change to unsync it? Or do I just deal with it? I dont want to unsync everything else if possible.

CodePudding user response:

You put forward a solution in the comment.

I think I can add it appropriately. In the enter image description here

CodePudding user response:

As you already found out, you can exclude specific settings from syncing by defining this in your JSON config:

"settingsSync.ignoredSettings": [
    "code-runner.executorMap",
]

This will prevent your defined executors for ALL languages from being synced, though. If you want to keep syncing all the other executors, you might want to change your executor command instead so that it is platform agnostic.

You can check if you're running on Mac or Linux using the uname command. A single line command chain to run a different command for each platform would look like this:

[[ $(uname -s) =~ ^Darwin ]] && (my_mac_commands) || (my_linux_commands)

So in your case you probably could define something like this to make the executor command work on both your platforms:

"python": "[[ $(uname -s) =~ ^Darwin ]] && cmd="clear && python3 -u" || cmd="py"; eval "$cmd"",
  • Related