Skip to content

Instantly share code, notes, and snippets.

@jkavanagh58
Created August 8, 2021 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkavanagh58/ef8945f6c5cc8d3879f33be35ad6643d to your computer and use it in GitHub Desktop.
Save jkavanagh58/ef8945f6c5cc8d3879f33be35ad6643d to your computer and use it in GitHub Desktop.
Copy Windows Terminal settings file for sharing/backup
[CmdletBinding()]
Param (
[parameter(Mandatory = $False, ValueFromPipeline = $True,
HelpMessage = "wt settings file")]
[System.IO.FileInfo]$wtSettings = 'C:\Users\johnk\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json',
[parameter(Mandatory = $False, ValueFromPipeline = $False,
HelpMessage = "Name of file for update")]
[System.String]$wtRepoFile = "wt_settings_jkav.json",
[parameter(Mandatory = $False, ValueFromPipeline = $True,
HelpMessage = "Path to local clone")]
[System.IO.DirectoryInfo]$wtRepoPath = 'C:\Users\johnk\Documents\github\slackgroup\Terminal',
[parameter(Mandatory = $False, ValueFromPipeline = $False,
HelpMessage = "Full repo path")]
[System.String]$wtrepoFullPath = (Join-Path -Path $wtRepoPath -ChildPath $wtRepoFile)
)
BEGIN {
Try {
# Verify wt settings file exists
$wtSettings.Exists
}
Catch {
Write-Warning -Message "Unable to find Windows Terminal Settings File"
EXIT
}
}
PROCESS {
Copy-Item $wtSettings -Destination $wtrepoFullPath
Set-Location $wtRepoPath
# Still working on this LF/CRLF thing
git local --global core.autocrlf false
git add $wtrepoFullPath
git commit -m "JK Updated Windows Terminal Settings file (auto)"
git push
}
END {
Remove-Variable -Name wtSettings
[System.GC]::Collect()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment