-
-
Save mikefrobbins/7f20932de3c1b941d03c8d7352452c1d to your computer and use it in GitHub Desktop.
Revisions
-
SteveL-MSFT revised this gist
Sep 13, 2022 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 7 # Version 1.2.12 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -79,10 +79,11 @@ function prompt { } } Set-PSReadLineOption -Colors @{ Selection = "`e[92;7m"; InLinePrediction = "`e[36;7;238m" } -PredictionSource HistoryAndPlugin Set-PSReadLineKeyHandler -Chord Shift+Tab -Function MenuComplete Set-PSReadLineKeyHandler -Chord Ctrl+b -Function BackwardWord Set-PSReadLineKeyHandler -Chord Ctrl+f -Function ForwardWord Set-PSReadLineKeyHandler -Chord F2 -Function SwitchPredictionView if ($IsWindows) { Set-PSReadLineOption -EditMode Emacs -ShowToolTips @@ -91,12 +92,12 @@ function prompt { } else { try { Import-PSUnixTabCompletion } catch [System.Management.Automation.CommandNotFoundException] { Install-Module Microsoft.PowerShell.UnixTabCompletion -Repository PSGallery -AcceptLicense -Force Import-PSUnixTabCompletion } } -
SteveL-MSFT revised this gist
Jun 18, 2021 . 1 changed file with 4 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 7 # Version 1.2.10 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -36,7 +36,7 @@ if ([System.IO.File]::Exists($latestVersionFile)) { } } $global:profile_initialized = $false function prompt { @@ -110,11 +110,10 @@ function prompt { $env:PATH += [System.IO.Path]::PathSeparator+ [System.IO.Path]::Combine("$HOME",'.dotnet') } } } if ($global:profile_initialized -ne $true) { $global:profile_initialized = $true Initialize-Profile } -
SteveL-MSFT revised this gist
Apr 14, 2021 . 1 changed file with 12 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 7 # Version 1.2.9 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -15,7 +15,7 @@ if ([System.IO.File]::Exists($latestVersionFile)) { $currentVersion = $matches.Version } if ([version]$latestVersion -gt $currentVersion) { Write-Verbose "Your version: $currentVersion" -Verbose Write-Verbose "New version: $latestVersion" -Verbose $choice = Read-Host -Prompt "Found newer profile, install? (Y)" @@ -44,10 +44,10 @@ function prompt { $null = Start-ThreadJob -Name "Get version of `$profile from gist" -ArgumentList $gistUrl, $latestVersionFile, $versionRegEx -ScriptBlock { param ($gistUrl, $latestVersionFile, $versionRegEx) try { $gist = Invoke-RestMethod $gistUrl -ErrorAction Stop $gistProfile = $gist.Files."profile.ps1".Content [version]$gistVersion = "0.0.0" if ($gistProfile -match $versionRegEx) { @@ -60,16 +60,16 @@ function prompt { Write-Verbose -Verbose "Was not able to access gist to check for newer version" } } if ((Get-Module PSReadLine).Version -lt 2.2) { throw "Profile requires PSReadLine 2.2+" } # setup psdrives if ([System.IO.File]::Exists([System.IO.Path]::Combine("$HOME",'test'))) { New-PSDrive -Root ~/test -Name Test -PSProvider FileSystem -ErrorAction Ignore > $Null } if (!(Test-Path repos:)) { if (Test-Path ([System.IO.Path]::Combine("$HOME",'git'))) { New-PSDrive -Root ~/repos -Name git -PSProvider FileSystem > $Null @@ -78,12 +78,12 @@ function prompt { New-PSDrive -Root D:\ -Name git -PSProvider FileSystem > $Null } } Set-PSReadLineOption -Colors @{ Selection = "`e[92;7m"; InLinePrediction = "`e[36;7;238m" } -PredictionSource History Set-PSReadLineKeyHandler -Chord Shift+Tab -Function MenuComplete Set-PSReadLineKeyHandler -Chord Ctrl+b -Function BackwardWord Set-PSReadLineKeyHandler -Chord Ctrl+f -Function ForwardWord if ($IsWindows) { Set-PSReadLineOption -EditMode Emacs -ShowToolTips Set-PSReadLineKeyHandler -Chord Ctrl+Shift+c -Function Copy @@ -99,18 +99,18 @@ function prompt { Import-UnixCompleters } } # add path to dotnet global tools $env:PATH += [System.IO.Path]::PathSeparator + [System.IO.Path]::Combine("$HOME",'.dotnet','tools') # ensure dotnet cli is in path $dotnet = Get-Command dotnet -CommandType Application -ErrorAction Ignore if ($null -eq $dotnet) { if ([System.IO.File]::Exists("$HOME/.dotnet/dotnet")){ $env:PATH += [System.IO.Path]::PathSeparator+ [System.IO.Path]::Combine("$HOME",'.dotnet') } } $profile_initialized = $true } -
SteveL-MSFT revised this gist
Apr 3, 2021 . 1 changed file with 79 additions and 65 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,15 @@ #Requires -Version 7 # Version 1.2.8 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" $latestVersionFile = [System.IO.Path]::Combine("$HOME",'.latest_profile_version') $versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)" if ([System.IO.File]::Exists($latestVersionFile)) { $latestVersion = [System.IO.File]::ReadAllText($latestVersionFile) $currentProfile = [System.IO.File]::ReadAllText($profile) [version]$currentVersion = "0.0.0" if ($currentProfile -match $versionRegEx) { $currentVersion = $matches.Version @@ -36,73 +36,87 @@ if (Test-Path $latestVersionFile) { } } $profile_initialized = $false function prompt { function Initialize-Profile { $null = Start-ThreadJob -Name "Get version of `$profile from gist" -ArgumentList $gistUrl, $latestVersionFile, $versionRegEx -ScriptBlock { param ($gistUrl, $latestVersionFile, $versionRegEx) try { $gist = Invoke-RestMethod $gistUrl -ErrorAction Stop $gistProfile = $gist.Files."profile.ps1".Content [version]$gistVersion = "0.0.0" if ($gistProfile -match $versionRegEx) { $gistVersion = $matches.Version Set-Content -Path $latestVersionFile -Value $gistVersion } } catch { # we can hit rate limit issue with GitHub since we're using anonymous Write-Verbose -Verbose "Was not able to access gist to check for newer version" } } if ((Get-Module PSReadLine).Version -lt 2.2) { throw "Profile requires PSReadLine 2.2+" } # setup psdrives if ([System.IO.File]::Exists([System.IO.Path]::Combine("$HOME",'test'))) { New-PSDrive -Root ~/test -Name Test -PSProvider FileSystem -ErrorAction Ignore > $Null } if (!(Test-Path repos:)) { if (Test-Path ([System.IO.Path]::Combine("$HOME",'git'))) { New-PSDrive -Root ~/repos -Name git -PSProvider FileSystem > $Null } elseif (Test-Path "d:\PowerShell") { New-PSDrive -Root D:\ -Name git -PSProvider FileSystem > $Null } } Set-PSReadLineOption -Colors @{ Selection = "`e[92;7m"; InLinePrediction = "`e[36;7;238m" } -PredictionSource History Set-PSReadLineKeyHandler -Chord Shift+Tab -Function MenuComplete Set-PSReadLineKeyHandler -Chord Ctrl+b -Function BackwardWord Set-PSReadLineKeyHandler -Chord Ctrl+f -Function ForwardWord if ($IsWindows) { Set-PSReadLineOption -EditMode Emacs -ShowToolTips Set-PSReadLineKeyHandler -Chord Ctrl+Shift+c -Function Copy Set-PSReadLineKeyHandler -Chord Ctrl+Shift+v -Function Paste } else { try { Import-UnixCompleters } catch [System.Management.Automation.CommandNotFoundException] { Install-Module Microsoft.PowerShell.UnixCompleters -Repository PSGallery -AcceptLicense -Force Import-UnixCompleters } } # add path to dotnet global tools $env:PATH += [System.IO.Path]::PathSeparator + [System.IO.Path]::Combine("$HOME",'.dotnet','tools') # ensure dotnet cli is in path $dotnet = Get-Command dotnet -CommandType Application -ErrorAction Ignore if ($null -eq $dotnet) { if ([System.IO.File]::Exists("$HOME/.dotnet/dotnet")){ $env:PATH += [System.IO.Path]::PathSeparator+ [System.IO.Path]::Combine("$HOME",'.dotnet') } } $profile_initialized = $true } if (!$profile_initialized) { Initialize-Profile } $currentLastExitCode = $LASTEXITCODE $lastSuccess = $? -
SteveL-MSFT revised this gist
Apr 2, 2021 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,15 @@ #Requires -Version 7 # Version 1.2.7 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" $latestVersionFile = [System.IO.Path]::Combine("$HOME",'.latest_profile_version') $versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)" if (Test-Path $latestVersionFile) { $latestVersion = Get-Content $latestVersionFile -ReadCount 0 $currentProfile = (Get-Content $profile -Raw -ReadCount 0)[0] [version]$currentVersion = "0.0.0" if ($currentProfile -match $versionRegEx) { $currentVersion = $matches.Version @@ -56,7 +56,7 @@ $null = Start-ThreadJob -Name "Get version of `$profile from gist" -ArgumentList } # add path to dotnet global tools $env:PATH += [System.IO.Path]::PathSeparator + [System.IO.Path]::Combine("$HOME",'.dotnet','tools') if ($IsWindows) { Set-PSReadLineOption -EditMode Emacs -ShowToolTips @@ -84,17 +84,17 @@ Set-PSReadLineKeyHandler -Chord Ctrl+f -Function ForwardWord $dotnet = Get-Command dotnet -CommandType Application -ErrorAction Ignore if ($null -eq $dotnet) { if (Test-Path ~/.dotnet/dotnet) { $env:PATH += [System.IO.Path]::PathSeparator+ [System.IO.Path]::Combine("$HOME",'.dotnet') } } # setup psdrives if ((Test-Path ([System.IO.Path]::Combine("$HOME",'test'))) -and (!(Test-Path test:))) { New-PSDrive -Root ~/test -Name Test -PSProvider FileSystem > $Null } if (!(Test-Path repos:)) { if (Test-Path ([System.IO.Path]::Combine("$HOME",'git'))) { New-PSDrive -Root ~/repos -Name git -PSProvider FileSystem > $Null } elseif (Test-Path "d:\PowerShell") { @@ -152,7 +152,7 @@ function prompt { $gitBranch = "" $path = Get-Location while ($path -ne "") { if (Test-Path ([System.IO.Path]::Combine($path,'.git'))) { # need to do this so the stderr doesn't show up in $error $ErrorActionPreferenceOld = $ErrorActionPreference $ErrorActionPreference = 'Ignore' -
SteveL-MSFT revised this gist
Feb 17, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 7 # Version 1.2.6 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -75,7 +75,7 @@ if ((Get-Module PSReadLine).Version -lt 2.2) { throw "Profile requires PSReadLine 2.2+" } Set-PSReadLineOption -Colors @{ Selection = "`e[92;7m"; InLinePrediction = "`e[36;7;238m" } -PredictionSource History Set-PSReadLineKeyHandler -Chord Shift+Tab -Function MenuComplete Set-PSReadLineKeyHandler -Chord Ctrl+b -Function BackwardWord Set-PSReadLineKeyHandler -Chord Ctrl+f -Function ForwardWord -
SteveL-MSFT revised this gist
Nov 5, 2020 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 7 # Version 1.2.5 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -71,12 +71,14 @@ else { Import-Module Microsoft.PowerShell.UnixCompleters } if ((Get-Module PSReadLine).Version -lt 2.2) { throw "Profile requires PSReadLine 2.2+" } Set-PSReadLineOption -Colors @{ Selection = "`e[92;7m"; InLinePrediction = "`e[36;7;238m" } -PredictionSource HistoryAndPlugin -PredictionViewStyle ListView Set-PSReadLineKeyHandler -Chord Shift+Tab -Function MenuComplete Set-PSReadLineKeyHandler -Chord Ctrl+b -Function BackwardWord Set-PSReadLineKeyHandler -Chord Ctrl+f -Function ForwardWord # ensure dotnet cli is in path $dotnet = Get-Command dotnet -CommandType Application -ErrorAction Ignore -
SteveL-MSFT revised this gist
Oct 20, 2020 . 1 changed file with 11 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.2.4 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -71,7 +71,8 @@ else { Import-Module Microsoft.PowerShell.UnixCompleters } Set-PSReadLineOption -Colors @{ Selection = "`e[92;7m" } Set-PSReadLineOption -Colors @{ InLinePrediction = "`e[36;7;238m" } Set-PSReadLineKeyHandler -Chord Shift+Tab -Function MenuComplete Set-PSReadLineKeyHandler -Chord Ctrl+b -Function BackwardWord Set-PSReadLineKeyHandler -Chord Ctrl+f -Function ForwardWord @@ -86,15 +87,17 @@ if ($null -eq $dotnet) { } # setup psdrives if ((Test-Path (Join-Path -Path ~ -ChildPath 'test')) -and (!(Test-Path test:))) { New-PSDrive -Root ~/test -Name Test -PSProvider FileSystem > $Null } if (!(Test-Path repos:)) { if (Test-Path (Join-Path -Path ~ -ChildPath 'git')) { New-PSDrive -Root ~/repos -Name git -PSProvider FileSystem > $Null } elseif (Test-Path "d:\PowerShell") { New-PSDrive -Root D:\ -Name git -PSProvider FileSystem > $Null } } function prompt { -
SteveL-MSFT revised this gist
Jun 6, 2020 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.2.3 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -75,6 +75,7 @@ Set-PSReadLineOption -Colors @{Selection = "`e[92;7m"} Set-PSReadLineKeyHandler -Chord Shift+Tab -Function MenuComplete Set-PSReadLineKeyHandler -Chord Ctrl+b -Function BackwardWord Set-PSReadLineKeyHandler -Chord Ctrl+f -Function ForwardWord Set-PSReadLineOption -PredictionSource History # ensure dotnet cli is in path $dotnet = Get-Command dotnet -CommandType Application -ErrorAction Ignore -
SteveL-MSFT revised this gist
Apr 27, 2020 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.2.2 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -84,6 +84,18 @@ if ($null -eq $dotnet) { } } # setup psdrives if (Test-Path (Join-Path -Path ~ -ChildPath 'test')) { New-PSDrive -Root ~/test -Name Test -PSProvider FileSystem > $Null } if (Test-Path (Join-Path -Path ~ -ChildPath 'repos')) { New-PSDrive -Root ~/repos -Name git -PSProvider FileSystem > $Null } elseif (Test-Path "d:\PowerShell") { New-PSDrive -Root D:\ -Name git -PSProvider FileSystem > $Null } function prompt { $currentLastExitCode = $LASTEXITCODE -
SteveL-MSFT revised this gist
Apr 18, 2020 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.2.1 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -55,17 +55,20 @@ $null = Start-ThreadJob -Name "Get version of `$profile from gist" -ArgumentList } } # add path to dotnet global tools $env:PATH += [System.IO.Path]::PathSeparator + (Join-Path (Resolve-Path ~) ".dotnet" "tools") if ($IsWindows) { Set-PSReadLineOption -EditMode Emacs -ShowToolTips Set-PSReadLineKeyHandler -Chord Ctrl+Shift+c -Function Copy Set-PSReadLineKeyHandler -Chord Ctrl+Shift+v -Function Paste } else { if ($null -eq (Get-Module Microsoft.PowerShell.UnixCompleters -listavailable)) { Install-Module Microsoft.PowerShell.UnixCompleters -Repository PSGallery -AcceptLicense -Force } Import-Module Microsoft.PowerShell.UnixCompleters } Set-PSReadLineOption -Colors @{Selection = "`e[92;7m"} -
SteveL-MSFT revised this gist
Jan 24, 2020 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.1.9 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -71,6 +71,7 @@ else { Set-PSReadLineOption -Colors @{Selection = "`e[92;7m"} Set-PSReadLineKeyHandler -Chord Shift+Tab -Function MenuComplete Set-PSReadLineKeyHandler -Chord Ctrl+b -Function BackwardWord Set-PSReadLineKeyHandler -Chord Ctrl+f -Function ForwardWord # ensure dotnet cli is in path $dotnet = Get-Command dotnet -CommandType Application -ErrorAction Ignore -
SteveL-MSFT revised this gist
Dec 17, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.1.8 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -91,6 +91,7 @@ function prompt { Green = "`e[32;1m" Yellow = "`e[33;1m" Grey = "`e[37;0m" White = "`e[37;1m" Invert = "`e[7m" RedBackground = "`e[41m" } -
SteveL-MSFT revised this gist
Nov 4, 2019 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.1.7 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -55,8 +55,6 @@ $null = Start-ThreadJob -Name "Get version of `$profile from gist" -ArgumentList } } if ($IsWindows) { Set-PSReadLineOption -EditMode Emacs -ShowToolTips Set-PSReadLineKeyHandler -Chord Ctrl+Shift+c -Function Copy @@ -70,6 +68,10 @@ else { Import-Module PSUnixUtilCompleters } Set-PSReadLineOption -Colors @{Selection = "`e[92;7m"} Set-PSReadLineKeyHandler -Chord Shift+Tab -Function MenuComplete Set-PSReadLineKeyHandler -Chord Ctrl+b -Function BackwardWord # ensure dotnet cli is in path $dotnet = Get-Command dotnet -CommandType Application -ErrorAction Ignore if ($null -eq $dotnet) { -
SteveL-MSFT revised this gist
Oct 28, 2019 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.1.6 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -80,6 +80,7 @@ if ($null -eq $dotnet) { function prompt { $currentLastExitCode = $LASTEXITCODE $lastSuccess = $? $color = @{ @@ -181,4 +182,6 @@ function prompt { } catch { # do nothing if can't be set } $global:LASTEXITCODE = $currentLastExitCode } -
SteveL-MSFT revised this gist
Oct 26, 2019 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.1.5 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -89,6 +89,7 @@ function prompt { Yellow = "`e[33;1m" Grey = "`e[37;0m" Invert = "`e[7m" RedBackground = "`e[41m" } # set color of PS based on success of last execution @@ -160,7 +161,7 @@ function prompt { # check if running dev built pwsh $devBuild = '' if ($PSHOME.Contains("publish")) { $devBuild = " $($color.White)$($color.RedBackground)DevPwsh$($color.Reset)" } "${lastCmdTime}${currentDirectory}${gitBranch}${devBuild}`n${lastExit}PS$($color.Reset)$('>' * ($nestedPromptLevel + 1)) " -
SteveL-MSFT revised this gist
Oct 20, 2019 . 1 changed file with 9 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.1.4 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -88,6 +88,7 @@ function prompt { Green = "`e[32;1m" Yellow = "`e[33;1m" Grey = "`e[37;0m" Invert = "`e[7m" } # set color of PS based on success of last execution @@ -156,7 +157,13 @@ function prompt { $currentDirectory = "`u{2026}" + $currentDirectory.SubString($currentDirectory.Length - $maxPath) } # check if running dev built pwsh $devBuild = '' if ($PSHOME.Contains("publish")) { $devBuild = " $($color.Red)$($color.Invert)DevPwsh$($color.Reset)" } "${lastCmdTime}${currentDirectory}${gitBranch}${devBuild}`n${lastExit}PS$($color.Reset)$('>' * ($nestedPromptLevel + 1)) " # set window title try { -
SteveL-MSFT revised this gist
Oct 13, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.1.3 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -64,7 +64,7 @@ if ($IsWindows) { } else { if ($null -eq (Get-Module PSUnixUtilCompleters -listavailable)) { Install-Module PSUnixUtilCompleters -Repository PSGallery -AcceptLicense -Force } Import-Module PSUnixUtilCompleters -
SteveL-MSFT revised this gist
Oct 13, 2019 . 1 changed file with 10 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.1.2 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" @@ -55,13 +55,20 @@ $null = Start-ThreadJob -Name "Get version of `$profile from gist" -ArgumentList } } Set-PSReadLineKeyHandler -Chord Ctrl+b -Function BackwardWord if ($IsWindows) { Set-PSReadLineOption -EditMode Emacs -ShowToolTips Set-PSReadLineKeyHandler -Chord Ctrl+Shift+c -Function Copy Set-PSReadLineKeyHandler -Chord Ctrl+Shift+v -Function Paste } else { if ($null -eq (Get-Module PSUnixUtilCompleters -listavailable)) { Install-Module PSUnixUtilCompleters -Repository PSGallery -Force } Import-Module PSUnixUtilCompleters } # ensure dotnet cli is in path $dotnet = Get-Command dotnet -CommandType Application -ErrorAction Ignore @@ -153,6 +160,7 @@ function prompt { # set window title try { $prefix = '' if ($isWindows) { $identity = [System.Security.Principal.WindowsIdentity]::GetCurrent() $windowsPrincipal = [Security.Principal.WindowsPrincipal]::new($identity) -
SteveL-MSFT revised this gist
Sep 30, 2019 . 1 changed file with 42 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,41 +1,58 @@ #Requires -Version 6 # Version 1.1.0 # check if newer version $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" $latestVersionFile = Join-Path -Path ~ -ChildPath ".latest_profile_version" $versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)" if (Test-Path $latestVersionFile) { $latestVersion = Get-Content $latestVersionFile $currentProfile = Get-Content $profile -Raw [version]$currentVersion = "0.0.0" if ($currentProfile -match $versionRegEx) { $currentVersion = $matches.Version } if ($latestVersion -gt $currentVersion) { Write-Verbose "Your version: $currentVersion" -Verbose Write-Verbose "New version: $latestVersion" -Verbose $choice = Read-Host -Prompt "Found newer profile, install? (Y)" if ($choice -eq "Y" -or $choice -eq "") { try { $gist = Invoke-RestMethod $gistUrl -ErrorAction Stop $gistProfile = $gist.Files."profile.ps1".Content Set-Content -Path $profile -Value $gistProfile Write-Verbose "Installed newer version of profile" -Verbose . $profile return } catch { # we can hit rate limit issue with GitHub since we're using anonymous Write-Verbose -Verbose "Was not able to access gist, try again next time" } } } } $null = Start-ThreadJob -Name "Get version of `$profile from gist" -ArgumentList $gistUrl, $latestVersionFile, $versionRegEx -ScriptBlock { param ($gistUrl, $latestVersionFile, $versionRegEx) try { $gist = Invoke-RestMethod $gistUrl -ErrorAction Stop $gistProfile = $gist.Files."profile.ps1".Content [version]$gistVersion = "0.0.0" if ($gistProfile -match $versionRegEx) { $gistVersion = $matches.Version Set-Content -Path $latestVersionFile -Value $gistVersion } } catch { # we can hit rate limit issue with GitHub since we're using anonymous Write-Verbose -Verbose "Was not able to access gist to check for newer version" } } if ($IsWindows) { @@ -44,6 +61,8 @@ if ($IsWindows) { Set-PSReadLineKeyHandler -Chord Ctrl+Shift+v -Function Paste } Set-PSReadLineKeyHandler -Chord Ctrl+b -Function BackwardWord # ensure dotnet cli is in path $dotnet = Get-Command dotnet -CommandType Application -ErrorAction Ignore if ($null -eq $dotnet) { -
SteveL-MSFT revised this gist
Jun 1, 2019 . 1 changed file with 7 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.0.9 # check if newer version try { @@ -99,10 +99,14 @@ function prompt { $path = Get-Location while ($path -ne "") { if (Test-Path (Join-Path $path .git)) { # need to do this so the stderr doesn't show up in $error $ErrorActionPreferenceOld = $ErrorActionPreference $ErrorActionPreference = 'Ignore' $branch = git rev-parse --abbrev-ref --symbolic-full-name '@{u}' $ErrorActionPreference = $ErrorActionPreferenceOld # handle case where branch is local if ($lastexitcode -ne 0 -or $null -eq $branch) { $branch = git rev-parse --abbrev-ref HEAD } -
SteveL-MSFT revised this gist
Apr 27, 2019 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.0.8 # check if newer version try { @@ -61,7 +61,7 @@ function prompt { Red = "`e[31;1m" Green = "`e[32;1m" Yellow = "`e[33;1m" Grey = "`e[37;0m" } # set color of PS based on success of last execution @@ -120,12 +120,13 @@ function prompt { # truncate the current location if too long $currentDirectory = $executionContext.SessionState.Path.CurrentLocation.Path $consoleWidth = [Console]::WindowWidth $maxPath = [int]($consoleWidth / 2) if ($currentDirectory.Length -gt $maxPath) { $currentDirectory = "`u{2026}" + $currentDirectory.SubString($currentDirectory.Length - $maxPath) } "$lastCmdTime$currentDirectory$gitBranch`n$($lastExit)PS$($color.Reset)$('>' * ($nestedPromptLevel + 1)) " # set window title try { -
SteveL-MSFT revised this gist
Apr 20, 2019 . 1 changed file with 30 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,35 +1,42 @@ #Requires -Version 6 # Version 1.0.7 # check if newer version try { $gist = Invoke-RestMethod https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e -ErrorAction Stop $gistProfile = $gist.Files."profile.ps1".Content $currentProfile = Get-Content $profile -Raw if ($gistProfile.GetHashCode() -ne $currentProfile.GetHashCode()) { [version]$currentVersion = "0.0.0" $versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)" if ($currentProfile -match $versionRegEx) { $currentVersion = $matches.Version } [version]$gistVersion = "0.0.0" if ($gistProfile -match $versionRegEx) { $gistVersion = $matches.Version } if ($gistVersion -gt $currentVersion) { Write-Verbose "Your version: $currentVersion" -Verbose Write-Verbose "New version: $gistVersion" -Verbose $choice = Read-Host -Prompt "Found newer profile, install? (Y)" if ($choice -eq "Y" -or $choice -eq "") { Set-Content -Path $profile -Value $gistProfile Write-Verbose "Installed newer version of profile" -Verbose . $profile return } } } } catch [WebCmdletWebResponseException] { # we can hit rate limit issue with GitHub since we're using anonymous Write-Verbose -Verbose "Was not able to access gist to check for newer version" } if ($IsWindows) { Set-PSReadLineOption -EditMode Emacs -ShowToolTips -
SteveL-MSFT revised this gist
Apr 5, 2019 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.0.6 # check if newer version $gist = Invoke-RestMethod https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e @@ -31,7 +31,11 @@ if ($gistProfile.GetHashCode() -ne $currentProfile.GetHashCode()) { } } if ($IsWindows) { Set-PSReadLineOption -EditMode Emacs -ShowToolTips Set-PSReadLineKeyHandler -Chord Ctrl+Shift+c -Function Copy Set-PSReadLineKeyHandler -Chord Ctrl+Shift+v -Function Paste } # ensure dotnet cli is in path $dotnet = Get-Command dotnet -CommandType Application -ErrorAction Ignore -
SteveL-MSFT revised this gist
Apr 3, 2019 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.0.5 # check if newer version $gist = Invoke-RestMethod https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e @@ -31,6 +31,8 @@ if ($gistProfile.GetHashCode() -ne $currentProfile.GetHashCode()) { } } Set-PSReadLineOption -EditMode Emacs -ShowToolTips # ensure dotnet cli is in path $dotnet = Get-Command dotnet -CommandType Application -ErrorAction Ignore if ($null -eq $dotnet) { -
SteveL-MSFT revised this gist
Mar 20, 2019 . 1 changed file with 10 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.0.4 # check if newer version $gist = Invoke-RestMethod https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e @@ -116,7 +116,15 @@ function prompt { # set window title try { if ($isWindows) { $identity = [System.Security.Principal.WindowsIdentity]::GetCurrent() $windowsPrincipal = [Security.Principal.WindowsPrincipal]::new($identity) if ($windowsPrincipal.IsInRole("Administrators") -eq 1) { $prefix = "Admin:" } } $Host.ui.RawUI.WindowTitle = "$prefix$PWD" } catch { # do nothing if can't be set } -
SteveL-MSFT revised this gist
Feb 21, 2019 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,14 @@ #Requires -Version 6 # Version 1.0.3 # check if newer version $gist = Invoke-RestMethod https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e $gistProfile = $gist.Files."profile.ps1".Content $currentProfile = Get-Content $profile -Raw if ($gistProfile.GetHashCode() -ne $currentProfile.GetHashCode()) { [version]$currentVersion = "0.0.0" $versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)" if ($currentProfile -match $versionRegEx) { $currentVersion = $matches.Version } @@ -19,10 +19,12 @@ if ($gistProfile.GetHashCode() -ne $currentProfile.GetHashCode()) { } if ($gistVersion -gt $currentVersion) { Write-Verbose "Your version: $currentVersion" -Verbose Write-Verbose "New version: $gistVersion" -Verbose $choice = Read-Host -Prompt "Found newer profile, install? (Y)" if ($choice -eq "Y" -or $choice -eq "") { Set-Content -Path $profile -Value $gistProfile Write-Verbose "Installed newer version of profile" -Verbose . $profile return } -
SteveL-MSFT revised this gist
Feb 21, 2019 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.0.2 # check if newer version $gist = Invoke-RestMethod https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e @@ -111,4 +111,11 @@ function prompt { } "$($lastExit)PS$($color.Reset) $lastCmdTime$currentDirectory$gitBranch$('>' * ($nestedPromptLevel + 1)) " # set window title try { $Host.ui.RawUI.WindowTitle = $PWD } catch { # do nothing if can't be set } } -
SteveL-MSFT revised this gist
Feb 9, 2019 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Requires -Version 6 # Version 1.0.1 # check if newer version $gist = Invoke-RestMethod https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e @@ -29,6 +29,14 @@ if ($gistProfile.GetHashCode() -ne $currentProfile.GetHashCode()) { } } # ensure dotnet cli is in path $dotnet = Get-Command dotnet -CommandType Application -ErrorAction Ignore if ($null -eq $dotnet) { if (Test-Path ~/.dotnet/dotnet) { $env:PATH += [System.IO.Path]::PathSeparator + (Join-Path (Resolve-Path ~) ".dotnet") } } function prompt { $lastSuccess = $? -
SteveL-MSFT revised this gist
Feb 1, 2019 . 1 changed file with 25 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,31 @@ #Requires -Version 6 # Version 1.0.0 # check if newer version $gist = Invoke-RestMethod https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e $gistProfile = $gist.Files."profile.ps1".Content $currentProfile = Get-Content $profile -Raw if ($gistProfile.GetHashCode() -ne $currentProfile.GetHashCode()) { [version]$currentVersion = "0.0.0" $versionRegEx = "# Version (version:.*?)\n" if ($currentProfile -match $versionRegEx) { $currentVersion = $matches.Version } [version]$gistVersion = "0.0.0" if ($gistProfile -match $versionRegEx) { $gistVersion = $matches.Version } if ($gistVersion -gt $currentVersion) { $choice = Read-Host -Prompt "Found newer profile, install? (Y)" if ($choice -eq "Y" -or $choice -eq "") { Set-Content -Path $profile -Value $gistProfile Write-Verbose "Installed newer version of profile" . $profile return } } }
NewerOlder