Skip to content

Instantly share code, notes, and snippets.

@drandarov-io
Created June 16, 2024 13:43
Show Gist options
  • Save drandarov-io/5a7e3db1900c22c1a5a6e01ed375cbfd to your computer and use it in GitHub Desktop.
Save drandarov-io/5a7e3db1900c22c1a5a6e01ed375cbfd to your computer and use it in GitHub Desktop.
# Update multiple packages
function wum {
<# .SYNOPSIS
Update multiple winget packages (supports -i). #>
Param([Parameter(Position = 0, Mandatory = $true)][string[]] $Packages)
foreach ($Package in $Packages) {
$Package = $Package.Trim()
Write-Host ("Upgrading {0} with 'winget upgrade $Package'..." -f $Package) -ForegroundColor Green
winget upgrade $Package
}
}
Register-ArgumentCompleter -Native -CommandName wum -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$Local:word = $wordToComplete.Replace('"', '""')
$Local:new_ast = "winget upgrade $word"
winget complete --word="$Local:word" --commandline "$Local:new_ast" --position $cursorPosition | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment