Demo.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# dull prompt
ipmo Powerline; Set-PowerlinePrompt
$function:prompt
# That's a little prettier ...
pushd .\Documents\WindowsPowerShell\
# Oh, I want to see the location stack size
Get-Location -Stack
if($pushd = (Get-Location -Stack).count) { "?" + $pushd }
# That'll work ... let's try putting that in our prompt
using module PowerLine
$PushLine = [PowerLineBlock]@{
    bg = "cyan";
    fg = "white"
    text = { if($pushd = (Get-Location -Stack).count) { "»" + $pushd } }
}
$PushLine
"$PushLine"
# Perfect, now let's insert that ...
$PowerLinePrompt
$PowerLinePrompt.Lines
$PowerLinePrompt.Lines[0].Blocks
$PowerLinePrompt.Lines[0].Blocks.Insert(2,$PushLine)
# Tada!!!
popd

# Now let's see about adding the elapsed time on the right side
$PromptLine = [PowerLine]::New(@(
    [PowerLineBlock]::Column # This is the column break, the rest is right-aligned
    [PowerLineBlock]@{ bg = "DarkGray";     fg = "white"; text = { Get-Elapsed } }
)
)
"$PromptLine"
# Looks good, we'll stick it in as the first line
$PowerLinePrompt.Lines.Insert(0, $PromptLine)
# And to make it overlap the previous output, set the count of "PrefixLines"
$PowerLinePrompt.PrefixLines = 1