Skip to content

Instantly share code, notes, and snippets.

@gfraiteur
Last active January 3, 2022 15:04
Show Gist options
  • Save gfraiteur/9895d986a889c7f3638795acae556f15 to your computer and use it in GitHub Desktop.
Save gfraiteur/9895d986a889c7f3638795acae556f15 to your computer and use it in GitHub Desktop.
My PowerShell profile
# Save this file to: C:\Users\GaelFraiteur\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
# PowerShell parameter completion shim for the dotnet CLI
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
# dotnet suggest shell start
$availableToComplete = (dotnet-suggest list) | Out-String
$availableToCompleteArray = $availableToComplete.Split([Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries)
Register-ArgumentCompleter -Native -CommandName $availableToCompleteArray -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$fullpath = (Get-Command $commandAst.CommandElements[0]).Source
$arguments = $commandAst.Extent.ToString().Replace('"', '\"')
dotnet-suggest get -e $fullpath --position $cursorPosition -- "$arguments" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
$env:DOTNET_SUGGEST_SCRIPT_VERSION = "1.0.1"
# dotnet suggest script end
Import-Module Posh-Git
# Defines the command alias `b`
function ExecuteBuildPs1 {
$directory = Get-Location
while ( -not $(Test-Path "$directory\Build.ps1") ) {
$directory = (Get-Item $directory).Parent.FullName
if ( $directory -eq $null ) {
Throw "This is not a source repo."
}
}
& "$directory\Build.ps1" @args
}
Set-Alias b ExecuteBuildPs1
# Set window title
$GitPromptSettings.WindowTitle = { Get-Location }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment