Created
November 5, 2021 13:26
-
-
Save brettmillerb/18df53470010f25cf1d197ca80675fb5 to your computer and use it in GitHub Desktop.
PowerShell function to set VSCode settings.json properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Set-VSCodeSetting { | |
<# | |
.SYNOPSIS | |
Function for setting VS Code settings from command line | |
.DESCRIPTION | |
This function allows programmatic update of VS Code settings.json file | |
.PARAMETER FontSize | |
The font size to set | |
.EXAMPLE | |
Set-VSCodeSetting -FontSize 16 | |
.EXAMPLE | |
Using the vsc alias and positional parameter to set the font size. | |
vsc 16 | |
#> | |
[cmdletbinding()] | |
[Alias('vsc')] | |
param ( | |
[Parameter(Position = 0)] | |
[int] | |
$FontSize = 12 | |
) | |
$settingsPath = '~/Library/Application Support/Code - Insiders/User/settings.json' | |
$settings = Get-Content -Path $settingsPath | | |
ConvertFrom-Json | |
$settings.'editor.fontSize' = $FontSize | |
Set-Content -Path $settingsPath -Value ($settings | ConvertTo-Json -Depth 5) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment