Skip to content

Instantly share code, notes, and snippets.

@brettmillerb
Created November 5, 2021 13:26
Show Gist options
  • Save brettmillerb/18df53470010f25cf1d197ca80675fb5 to your computer and use it in GitHub Desktop.
Save brettmillerb/18df53470010f25cf1d197ca80675fb5 to your computer and use it in GitHub Desktop.
PowerShell function to set VSCode settings.json properties
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