-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RepeatPrompt instead of NoCache or Transient
- Loading branch information
Showing
10 changed files
with
117 additions
and
106 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,46 @@ | ||
#requires -module @{ModuleName='PowerLine';ModuleVersion='3.4.0'} | ||
# If this is re-run, clear up the old job: | ||
Get-Job -Name WeatherQuery -EA 0 | Stop-Job -PassThru | Remove-Job | ||
$global:WeatherJob = Start-ThreadJob -Name WeatherQuery { | ||
|
||
# If this is re-run, clear up the old job, and start a new one | ||
Get-Job -Name WeatherQuery -ErrorAction Ignore | Stop-Job -PassThru | Remove-Job | ||
$null = Start-ThreadJob -Name WeatherQuery { | ||
while ($true) { | ||
Invoke-RestMethod "wttr.in?format=%c%t" | ||
(Invoke-RestMethod "wttr.in?format=%c%t") -replace " +", " " | ||
Start-Sleep 300 # This job will update the weather every 5 minutes | ||
} | ||
} | ||
|
||
Set-PowerLinePrompt -SetCurrentDirectory -PowerLineFont -SimpleTransient -Title { | ||
$ContinuationPromptColor = [RgbColor]"DeepSkyBlue" | ||
|
||
Set-PSReadLineOption -ContinuationPrompt █ -Colors @{ ContinuationPrompt = $ContinuationPromptColor.ToVt() } | ||
|
||
Set-PowerLinePrompt -SetCurrentDirectory -PowerLineFont -RepeatPrompt LastLine -PSReadlineErrorColor Tomato -Title { | ||
-join @( | ||
if (Test-Elevation) { "Admin: " } | ||
"PS" + $PSVersionTable.PSVersion.Major + " " | ||
Convert-Path $pwd | ||
) | ||
} -Prompt @( | ||
Show-ElapsedTime -Autoformat -BackgroundColor 00688B -ForegroundColor White | ||
Show-ElapsedTime -Autoformat -Bg White -Fg Black -Prefix "" -Caps '','' | ||
New-TerminalBlock -Newline | ||
New-TerminalBlock { | ||
# Consume the output of the job: | ||
# In this case, I only want the most recent output, so [-1] | ||
$global:WeatherJob.Output[-1] | ||
} -BackgroundColor 00BFFF -ForegroundColor Black | ||
Show-NestedPromptLevel -RepeatCharacter "&Gear;" -Postfix " " -BackgroundColor 473C8B -ForegroundColor White | ||
Show-Path -HomeString "&House;" -Separator '' -Bg B23AEE -Fg White | ||
Show-PoshGitStatus -Bg Gray30 | ||
|
||
Show-Date -Format "h\:mm" -Bg DeepSkyBlue -Fg Black | ||
Show-JobOutput -Name WeatherQuery -Bg DeepSkyBlue3 -Fg Black | ||
Show-NestedPromptLevel -RepeatCharacter "&Gear;" -Postfix " " -Bg DeepSkyBlue4 -Fg White | ||
New-TerminalBlock -Spacer | ||
Show-Date -Bg 7D26CD | ||
|
||
Show-PoshGitStatus -Bg Gray30 | ||
Show-Path -HomeString "&House;" -Separator '' -Bg SkyBlue4 -Fg White | ||
New-TerminalBlock -Newline | ||
|
||
# This is basically Show-HistoryId, but I want to use it as the last part of my prompt, and have PSReadLine updated. | ||
New-TerminalBlock { | ||
# In order for PSReadLine to work properly, it needs the $PromptText set to match the end of my prompt... | ||
$MyInvocation.HistoryId | ||
|
||
# Because I don't have a "Write-TerminalBlock" I am doing all this by hand:This is | ||
# Need to draw ">ID>" but the > each have to be FOREGROUND = the BACKGROUND of the previous block | ||
# AND the color changes depending on whether nestedPrompt rendered or not | ||
[string]$CS = [PoshCode.Pansies.Entities]::ExtendedCharacters["ColorSeparator"] | ||
$thisBg = $NestedPromptLevel ? $bg:SteelBlue2 : $bg:SkyBlue2 | ||
$previousFg = $NestedPromptLevel ? $fg:SkyBlue2 : $fg:DeepSkyBlue2 | ||
$thisFg = $NestedPromptLevel ? $fg:SteelBlue2 : $fg:SkyBlue2 | ||
|
||
Set-PSReadlineOption -PromptText @( | ||
($thisBg + $previousFg + $CS + $fg:white + $MyInvocation.HistoryId + $thisFg + $bg:clear + $CS) | ||
($bg:Gray44 + $previousFg + $CS + $fg:white + $MyInvocation.HistoryId + $fg:Gray44 + $bg:clear + $CS) | ||
) | ||
} -BackgroundColor SteelBlue2 -ForegroundColor Black | ||
# New-TerminalBlock { | ||
# # In order for PSReadLine to work properly, it needs the $PromptText set to match the end of my prompt... | ||
# $ContinuationPromptColor = (Get-PSReadLineOption).ContinuationPromptColor | ||
# $fg:Black + ($ContinuationPromptColor -replace "\[3","[4") + "&ColorSeparator;" + $ContinuationPromptColor + $bg:LightSkyBlue + "&ColorSeparator;" + $Fg:Black + $MyInvocation.HistoryId | ||
|
||
# } -BackgroundColor LightSkyBlue -ForegroundColor Black | ||
# New-TerminalBlock -Spacer | ||
New-TerminalBlock -Content "&ColorSeparator;" -Background $ContinuationPromptColor -Foreground Black | ||
Show-HistoryId -Bg LightSkyBlue -Fg Black | ||
) | ||
|
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters