Skip to content

Instantly share code, notes, and snippets.

@mhudasch
Last active May 23, 2025 19:32
Show Gist options
  • Save mhudasch/5e7156ac5de473fa4f4e20aadf1894d7 to your computer and use it in GitHub Desktop.
Save mhudasch/5e7156ac5de473fa4f4e20aadf1894d7 to your computer and use it in GitHub Desktop.
The ultimate ps profile for devs
########################################
## Initial data collection inside the host
########################################
$OutputEncoding = [System.Text.Encoding]::Default;
[Console]::OutputEncoding = $OutputEncoding;
$InformationPreference = "Continue";
if ($([System.Environment]::GetCommandLineArgs() -join " ") -inotmatch "(?i)-(?:nologo|noniteractive|noecho)" -and
($([System.Environment]::GetCommandLineArgs() -join " ") -inotmatch "(?i)-command" -or
($([System.Environment]::GetCommandLineArgs() -join " ") -imatch "(?i)-command" -and $([System.Environment]::GetCommandLineArgs() -join " ") -inotmatch ('(?i)\' + $([io.path]::DirectorySeparatorChar) + '(?i)\\(?:.*?(?<!shellIntegration|hr))\.ps1')))) {
$__p = New-Object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent());
$__admin = $__p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator);
$__vt = $host.UI.SupportsVirtualTerminal;
########################################
## Find default browser
########################################
$__b = ([scriptblock] {
New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null;
$progId = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice" -Name "ProgId" |
Select-Object -ExpandProperty "ProgId";
$htmlCommand = $(Get-ItemProperty -Path "HKCR:\$($progId)\shell\open\command" -Name "(Default)").PSObject.Properties["(Default)"].Value;
$executable = if ($htmlCommand) {
$execMatch = [regex]::Match($htmlCommand, '"([^"]+)"|(.+?) ');
if ($execMatch.Success) {cls
$execMatch.Groups[1].Value;
} else {
$null;
}
} else {
$null;
}
(New-Object "pscustomobject" -Property ([ordered]@{
ProgramId = $progId;
OpenHtmlFileCommand = $htmlCommand;
Executable = $executable;
})) | Write-Output;
}).InvokeReturnAsIs();
########################################
## !! Set default search engine
## Change this if you want a different behavior
########################################
$__se = ([scriptblock] {
$name = "DuckDuckGo";
$base = "https://duckduckgo.com/";
(New-Object "pscustomobject" -Property ([ordered]@{
Name = $name;
WebSearch = $($base + "?q={{query}}&kl=en-us&kp=-1&kn=1&iax=web&ia=web");
ImageSearch = $($base + "?q={{query}}&kl=en-us&kp=-1&kn=1&iax=images&ia=images");
VideoSearch = $($base + "?q={{query}}&kl=en-us&kp=-1&kn=1&iax=videos&ia=videos");
LocationSearch = $($base + "?q={{query}}&kl=en-us&kp=-1&kn=1&iaxm=maps");
CodeSearch = $($base + "?q={{query}}+site%3Ahttps%3A%2F%2Fstackoverflow.com&kl=en-us&kp=-1&kn=1&iax=web&ia=web");
})) | Write-Output;
}).InvokeReturnAsIs();
########################################
## !! Self-Executing Hello Logo
## Change this if you want a better or other format
########################################
$__u = ([scriptblock] {
param($p)
$OriginalPref = $ProgressPreference # Default is 'Continue'
$ProgressPreference = "SilentlyContinue";
$calledArgs = [System.Environment]::GetCommandLineArgs() -join " ";
if ($calledArgs -inotmatch "(?i)-(?:nologo|noniteractive|noecho)") {
# not started as non-interactive shell
if ($calledArgs -inotmatch "(?i)-command" -and $calledArgs -inotmatch "(?i)\$([io.path]::DirectorySeparatorChar).*?\.ps1") {
# not started as a ps1 script execution shell
$u = $null;
if ($null -ne (Get-Module -Name "ActiveDirectory" -ListAvailable -ErrorAction Ignore)) {
Import-Module -Name ActiveDirectory -Verbose:($false);
$u = Get-ADUser -Filter { SID -eq $p.Identity.User.Value } -ErrorAction "Ignore";
}
return $u;
}
}
$ProgressPreference = $OriginalPref;
return $null;
}).InvokeReturnAsIs($__p);
########################################
## !! Hello message
## Change this if you want a better or other format
########################################
([scriptblock] {
param($u)
$esc = [char]0x1B;
$bg = 0; #$([int]$host.UI.RawUI.BackgroundColor);
if ($u) {
$name = "{0} {1} ({2})" -f $u.GivenName, $u.SurName, $u.SamAccountName;
} else {
$name = $($__p.Identity.Name);
}
$t = "Hello $name";
if ($__admin) {
$fg = "41";
} else {
$fg = "42";
}
$hello = if ($__vt) {
"${esc}[38;5;$bg;$($fg)m $t ${esc}[0m";
} else {
" $t "
}
Write-Host $hello;
Write-Host "";
}).InvokeReturnAsIs($__u);
########################################
## !! PROMPT Override
## Change this if you want a better or other format
########################################
if ($null -ne $(Get-Command -Name "oh-my-posh" -ErrorAction "Ignore")) {
oh-my-posh --init --shell pwsh --config "$PSScriptRoot\myprompt.json" | Invoke-Expression;
function Update-OhMyPoshProfile {
if (-not(Test-Path -Path "$PSScriptRoot\myprompt.json")) {
touch "$PSScriptRoot\myprompt.json";
}
edit "$PSScriptRoot\myprompt.json"
}
Set-Alias -Name "uomp" -Value "Update-OhMyPoshProfile"
} else {
function prompt {
$origLastExitCode = $LASTEXITCODE;
$lastExecutionTime = "";
$lastCmd = Get-History -Count 1;
if ($null -ne $lastCmd) {
$took = $lastCmd.EndExecutionTime - $lastCmd.StartExecutionTime;
$niceTook = (($took | Select-Object @{n = "t"; e = { @(@{v = $_.Hours; s = "$($_.Hours)h" }, @{v = $_.Minutes; s = "$($_.Minutes)m" }, @{v = $_.Seconds; s = "$($_.Seconds)s" }, @{v = $_.Milliseconds; s = "$($_.Milliseconds)ms" }) } }).t |
Where-Object { $_["v"] -gt 0 } | ForEach-Object { $_["s"] }) -join "";
$lastExecutionTime = "$([char]0x2191)$niceTook ";
}
$esc = [char]0x1B;
$cnt = $((Get-History -Count 1).id + 1);
$cn = "$env:COMPUTERNAME".ToUpperInvariant();
$bg = 0; #$([int]$host.UI.RawUI.BackgroundColor);
if ($__u) {
$name = "{0} {1} ({2})" -f $__u.GivenName, $__u.SurName, $__u.SamAccountName;
} else {
$name = $($__p.Identity.Name);
}
if ($__admin) {
$token = " A ";
$fg = "41";
} else {
$token = " U ";
$fg = "42";
}
$pre = if ($__vt) {
"${esc}[38;5;" + $bg + ";$($fg)m$lastExecutionTime[$cnt]$token$cn | $name | $(Get-Date -format "dd.MM.yyyy HH:mm:ss") ${esc}[0m ";
} else {
$token
}
Write-Host $pre;
$promptStringStart = (Get-Location).Path;
Write-Host $promptStringStart
$post += "$(if ($PsDebugContext) {' [DBG]:'} else {''})$('>' * ($nestedPromptLevel + 1)) ";
$LASTEXITCODE = $origLastExitCode;
return $post;
}
}
########################################
## !! Default Explorer settings
## Change this if you want a different behavior
########################################
function Reset-Explorer {
# check current setting where the exlorer starts to
$l = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "LaunchTo" -ErrorAction "Ignore"
# fix it to start always from "my computer"
if (($null -eq $l) -or (1 -ne $l)) {
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "LaunchTo" -Value 1
}
# check current setting if each explorer runs in separate process
$l = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "SeparateProcess" -ErrorAction "Ignore"
# fix it to start each process in separate process
if (($null -eq $l) -or (1 -ne $l)) {
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "SeparateProcess" -Value 1
}
# check current setting if explorer always shows file extensions
$l = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -ErrorAction "Ignore"
# fix it to always show file extensions (by not hiding it)
if (($null -eq $l) -or (0 -ne $l)) {
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -Value 0
}
}
########################################
## VisualStudio shortcuts
########################################
function vs {
$Sku = "Community";
$Version = 2022;
$vsPath = if ($Version -lt 2022) {
"C:\Program Files (x86)\Microsoft Visual Studio\$Version\$Sku\Common7\IDE\devenv.exe"
} else {
"C:\Program Files\Microsoft Visual Studio\$Version\$Sku\Common7\IDE\devenv.exe"
}
if (!$args) {
$sln = Get-ChildItem -Path (Get-Location).Path -File -Filter "*.sln" | Select-Object -ExpandProperty "FullName" -First 1;
if ($sln) {
& $vsPath $sln
return;
}
$csproj = Get-ChildItem -Path (Get-Location).Path -File -Filter "*.csproj" | Select-Object -ExpandProperty "FullName" -First 1;
if ($csproj) {
& $vsPath $csproj
return;
}
}
& $vsPath $args
}
########################################
## Editor shortcuts
########################################
if (Get-Command "code" -ErrorAction Ignore) {
function npp {
if ($args) {
code $args --new-window
} else {
code --new-window
}
}
Set-Alias -Name "n" -Value "npp";
Set-Alias -Name "edit" -Value "npp";
} elseif (Get-Command "notepadplusplus" -ErrorAction Ignore) {
function npp {
& notepadplusplus.exe $args
}
Set-Alias -Name "n" -Value "npp";
Set-Alias -Name "edit" -Value "npp";
Set-Alias -Name "code" -Value "npp";
} else {
function npp {
& notepad.exe $args;
}
Set-Alias -Name "n" -Value "npp";
Set-Alias -Name "edit" -Value "npp";
Set-Alias -Name "code" -Value "npp";
}
########################################
## Default browser shortcuts
########################################
function browser {
& "$($__b.Executable)" $args
}
if ($__b.ProgramId -ieq "MSEdgeHTM" -or $__b.ProgramId -ieq "ChromeHTML") {
function _tab {
param([string]$url = "$(<#tab system#>if($__b.ProgramId -ieq "MSEdgeHTM"){'edge'}else{'chrome'})://newtab")
browser "-new-tab" $url
}
} elseif ($__b.ProgramId -imatch "FirefoxHTML") {
function _tab {
param([string]$url = "about:newtab")
browser "--new-tab" "--url" $url
}
} else {
# browser not supported
$__b = $null;
}
if ($__b) {
Set-Alias -Name "browse" -Value "_tab";
if ($__se) {
function _find {
param([Parameter(ValueFromPipeline = $true)][string]$query = "%20")
browse -url $($__se.WebSearch.Replace("{{query}}", $query))
}
function _img {
param([Parameter(ValueFromPipeline = $true)][string]$query = "%20")
browse -url $($__se.ImageSearch.Replace("{{query}}", $query))
}
function _vid {
param([Parameter(ValueFromPipeline = $true)][string]$query = "%20")
browse -url $($__se.VideoSearch.Replace("{{query}}", $query))
}
function _loc {
param([Parameter(ValueFromPipeline = $true)][string]$query = "%20")
browse -url $($__se.LocationSearch.Replace("{{query}}", $query))
}
function _src {
param([Parameter(ValueFromPipeline = $true)][string]$query = "%20")
browse -url $($__se.CodeSearch.Replace("{{query}}", $query))
}
Set-Alias -Name "_search" -Value "_find";
}
}
########################################
## Explorer Utility shortcuts
########################################
function show {
if ($args) {
explorer $args
} else {
explorer .
}
}
########################################
## Other command-line utilities
########################################
function which {
param(
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
[string]$Command
)
$r = Get-Command -Name $Command -ErrorAction Ignore |
Select-Object -ExpandProperty "Path" -ErrorAction Ignore;
if(!$r -and $(Get-Command -Name "git" -ErrorAction Ignore)){
$r = & "C:\Program Files\Git\usr\bin\which.exe" $Command;
if($r) {
$r = $(($r -replace "\/([a-z])\/(.*?)", "`$1:\`$2") -replace "\/", "\");
}
}
$r | Write-Output;
}
Set-Alias -Name "whereis" -Value "which";
function workdir {
param(
[Parameter(Mandatory, ValueFromPipeline)]
[io.directoryInfo]$Name
)
$item = New-Item -Path $Name -ItemType Directory -Force
$item | Set-Location
}
Set-Alias -Name "wkdir" -Value "workdir"
function Set-ItemTime {
param(
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
[string[]]$Path,
[Alias("c")]
[switch]$NoCreate,
[Alias("a")]
[switch]$OnlyAccessTime,
[Alias("m")]
[switch]$OnlyModifyTime
);
process {
foreach ($itemPath in @($Path)) {
if (![io.Path]::IsPathRooted($itemPath)) {
$loc = (Get-Location).ProviderPath;
$itemPath = $(Join-Path -Path $loc -ChildPath $itemPath);
}
if (!$NoCreate.IsPresent -and -not(Test-Path -LiteralPath $itemPath)) {
# do not use set-content here because it creates utf-with-bom but we want utf8
[System.IO.File]::WriteAllLines($itemPath, "");
$resolvedItemPath = $itemPath;
} else {
$resolvedItemPath = Resolve-Path -LiteralPath $itemPath;
}
$itemInfo = $null;
if (Test-Path -LiteralPath $resolvedItemPath -PathType Container) {
$itemInfo = New-Object -TypeName "System.IO.DirectoryInfo" -ArgumentList $resolvedItemPath;
} else {
$itemInfo = New-Object -TypeName "System.IO.FileInfo" -ArgumentList $resolvedItemPath;
}
if ($itemInfo) {
$dt = [System.DateTime]::UtcNow;
if ($OnlyAccessTime.IsPresent) {
$itemInfo.LastAccessTimeUtc = $dt;
} elseif ($OnlyModifyTime) {
$itemInfo.LastWriteTimeUtc = $dt;
} else {
$itemInfo.CreationTimeUtc = $dt;
$itemInfo.LastAccessTimeUtc = $dt;
$itemInfo.LastWriteTimeUtc = $dt;
}
} else {
Write-Warning -Message "The item '$itemPath' does not exist.";
}
}
}
}
Set-Alias -Name "touch" -value "Set-ItemTime";
function ld {
Get-ChildItem | Where-Object { $_ -is [io.directoryInfo] }
}
function Set-LineEnding {
param(
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
[string[]]$Path,
[Parameter(Position = 1, Mandatory = $false)]
[Alias("Ending", "e", "m")]
[ValidateSet("CRLF", "LF")]
[string]$Mode = $(if ($psversiontable.OS -imatch "windows") {
"CRLF"
} else {
"LF"
})
)
process {
foreach ($itemPath in @($Path)) {
if (![io.Path]::IsPathRooted($itemPath)) {
$loc = (Get-Location).ProviderPath;
$itemPath = $(Join-Path -Path $loc -ChildPath $itemPath);
}
if (Test-Path -Path $itemPath) {
$itemLines = [io.file]::ReadAllLines($itemPath);
$itemText = [io.file]::ReadAllText($itemPath);
if ($itemText.Length -gt 0) {
$joinedLines = if ($Mode -eq "CRLF") {
$itemLines -join "`r`n"
} else {
$itemLines -join "`n"
}
# preserve last empty line
if ($itemText[-1] -eq "`n") {
$joinedLines += if ($Mode -eq "CRLF") {
"`r`n"
} else {
"`n"
}
}
[io.file]::WriteAllText($itemPath, $joinedLines);
}
}
}
}
}
Set-Alias -Name "crlf" -Value "Set-LineEnding"
# other aliases
Set-Alias -Name "clip" -Value "Set-Clipboard";
Set-Alias -Name "ll" -Value "dir";
########################################
## Only do this when git is installed
########################################
if (Get-Command -Name "git" -ErrorAction Ignore) {
Set-Alias -Name "g" -Value "git";
Set-Alias -Name "tig" -Value "C:\Program Files\Git\usr\bin\tig.exe";
Set-Alias -Name "less" -Value "C:\Program Files\Git\usr\bin\less.exe";
Set-Alias -Name "touch" -value "C:\Program Files\Git\usr\bin\touch.exe";
Set-Alias -Name "tail" -value "C:\Program Files\Git\usr\bin\tail.exe";
Set-Alias -Name "rnano" -value "C:\Program Files\Git\usr\bin\rnano.exe";
Set-Alias -Name "nano" -value "C:\Program Files\Git\usr\bin\rnano.exe";
function Update-GitConfig {
edit "~/.gitconfig"
}
Set-Alias -Name "ugc" -Value "Update-GitConfig";
}
########################################
## Only do this when yarn is installed
########################################
if (Get-Command -Name "yarn" -ErrorAction Ignore) {
Set-Alias -Name "y" -Value "yarn";
function Update-NpmConfig {
edit "$home\.npmrc"
}
Set-Alias -Name "unpc" -Value "Update-NpmConfig";
}
########################################
## Only do this when curl is installed
########################################
if (Get-Command -Name "C:\ProgramData\Chocolatey\bin\curl.exe" -ErrorAction Ignore) {
Set-Alias -Name "curl" -Value "C:\ProgramData\Chocolatey\bin\curl.exe" -Force -Option AllScope;
} elseif (Get-Command -Name "$env:SystemRoot\system32\curl.exe" -ErrorAction Ignore) {
Set-Alias -Name "curl" -Value "$env:SystemRoot\system32\curl.exe" -Force -Option AllScope;
}
########################################
## Only do this when docfx is installed
########################################
if (Get-Command "docfx" -ErrorAction Ignore) {
function doc {
docfx $args
}
}
########################################
## Only do this when chocolatey is installed
########################################
if (Get-Command "choco" -ErrorAction Ignore) {
function crm {
choco uninstall $args
}
function cfind {
choco find $args
}
}
########################################
## Only do this when 7zip is installed
########################################
if (Get-Command "7z" -ErrorAction Ignore) {
function pack {
& "7z" $args
}
function zip {
pack $args;
}
function compress {
pack $args;
}
function compact {
pack $args;
}
function pack-repo {
$n = "$([io.DirectoryInfo]::new((Get-Location).Path).Name).7z"; if (Test-Path -Path ".\$n") {
Remote-Item -Path ".\$n" -Force
} & "C:\Program Files\7-Zip\7z.exe" a -t7z $n .\ -mx9 -y -xr!'bin' -xr!'obj' -xr!'.git' -xr!'packages' -xr!'log*' -xr!'*.7z' -xr!'.vs' -xr!'TestResults' -xr!'MigrationBackup' -xr!'node_modules' -xr!'binaries' -xr!'publish' -xr!'*cache' $args
}
}
########################################
## Only do this when PSReadLine is installed
########################################
if (Get-Module "PSReadLine" -ListAvailable) {
$secureHistoreHandler = [scriptblock] {
param([string]$line)
$obviousSecretPatterns = @(
'\"?[pP]assword\"?\s*[\=\:]\s*\"?.+?\"?',
'\"?[pP]wd\"?\s*[\=\:]\s*\"?.+?\"?',
'\"?[pP][aA][tT]\"?\s*[\=\:]\s*\"?.+?\"?',
'\"?[aA][pP][iI][kK][eE][yY]\"?\s*[\=\:]\s*\"?.+?\"?',
'\"?([cC]lient)?[Ss]ecret\"?\s*[\=\:]\s*\"?.+?\"?',
'\"?([cC]lient)?[Ss]ecret\"?\s*[\=\:]\s*\"?.+?\"?',
'\"?([aA]uth)?[tT]oken\"?\s*[\=\:]\s*\"?.+?\"?',
'\-[aA]s[Pp]lain[tT]ext'
);
if (@($obviousSecretPatterns | Where-Object { $line -match $_ }).Count -gt 0) {
return $false;
}
# the vscode node debugger pollutes the history with its long commands
if ($line -imatch "VSCODE_INSPECTOR_OPTIONS") {
return $false;
}
# avoid saving short commands
if ($line.Length -lt 4) {
return $false;
}
# when the command contains long base64 encoded parts it might contain secrets
if ($line.Length -gt 25 -and $line -match '[\"\''](?:[A-Za-z\d+\/]{4})*(?:[A-Za-z\d+\/]{3}=|[A-Za-z\d+\/]{2}==)?[\"\'']') {
return $false
}
return $true;
}
Set-PSReadLineOption -AddToHistoryHandler $secureHistoreHandler;
Set-PSReadLineOption -HistoryNoDuplicates;
Set-PSReadLineOption -MaximumHistoryCount 5000;
Set-PSReadLineOption -BellStyle None;
Set-PSReadLineOption -PredictionSource History;
Set-PSReadLineOption -PredictionViewStyle ListView;
Set-PSReadLineKeyHandler -Chord 'Ctrl+d' -Function DeleteChar;
Remove-PSReadLineKeyHandler -Chord "Ctrl+@"
Set-PSReadLineKeyHandler -Chord "Ctrl+`"" -Function MenuComplete;
}
########################################
## Only do this when PSFzF is installed
########################################
if (Get-Module "PSFzF" -ListAvailable) {
Import-Module -Name "PSFzF";
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+f' -PSReadlineChordReverseHistory 'Ctrl+r';
Set-PSReadLineKeyHandler -Chord 'Alt-e' -ScriptBlock { Invoke-FuzzyEdit }
if (Get-Command "ag" -ErrorAction Ignore) {
Set-PSReadLineKeyHandler -Chord 'Alt-f' -ScriptBlock {
$m = $(ag --nobreak --noheading --ignore node_modules --nocolor . |
Invoke-Fzf |
Select-String "^([^\:]+\:\d+)\:|^([^\:]+)\:" |
ForEach-Object -MemberName "Matches" |
ForEach-Object {
if (!$_.Groups[1].Value) {
$_.Groups[2].Value
} else {
$_.Groups[1].Value
}
});
if($m) {
code --goto $m
} else {
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}
}
}
}
########################################
## Only do this when Terminal-Icons is installed
########################################
if (Get-Module "Terminal-Icons" -ListAvailable) {
Import-Module -Name "Terminal-Icons";
}
########################################
## Global Configuration shortcuts
########################################
function Update-PSProfile {
if ($host.Name -match "ise" -and $psISE) {
# when we are in the ise open the profile in the ise as well
$psISE.CurrentPowerShellTab.Files.Add($profile)
} else {
# otherwise open in preferred editor
edit $profile
}
}
Set-Alias -Name "ups" -Value "Update-PSProfile";
function Update-NuGetConfig {
param(
[ValidateSet("User", "Machine", "Project")]
[string]$Scope = "Project"
)
switch ($Scope) {
'User' {
edit "$($env:AppData)\NuGet\NuGet.config"
}
'Machine' {
edit "$(${env:ProgramFiles(x86)})\NuGet\Config"
}
'Project' {
if (Test-Path -Path ".\NuGet.config") {
edit ".\NuGet.config"
}
# support old nuget clients
elseif (Test-Path -Path ".\.nuget\NuGet.config") {
edit ".\.nuget\NuGet.config"
} else {
Write-Warning -Message "Could not find any project nuget.config file.";
}
}
}
}
Set-Alias -Name "unc" -Value "Update-NuGetConfig";
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
# dotnet suggest shell start
# if (Get-Command "dotnet-suggest" -errorAction SilentlyContinue) {
# $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', $_)
# }
# }
# }
# else {
# "Unable to provide System.CommandLine tab completion support unless the [dotnet-suggest] tool is first installed."
# "See the following for tool installation: https://www.nuget.org/packages/dotnet-suggest"
# }
#$env:DOTNET_SUGGEST_SCRIPT_VERSION = "1.0.2"
# dotnet suggest script end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment