forked from JeremySkinner/posh-hg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHgPrompt.ps1
88 lines (70 loc) · 3.69 KB
/
HgPrompt.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# For backwards compatibility
$global:HgPromptSettings = $global:PoshHgSettings
function Write-HgStatus($status = (get-hgStatus)) {
if ($status) {
$s = $global:PoshHgSettings
$branchFg = $s.BranchForegroundColor
$branchBg = $s.BranchBackgroundColor
if($status.Behind) {
$branchFg = $s.Branch2ForegroundColor
$branchBg = $s.Branch2BackgroundColor
}
Write-Host $s.BeforeText -NoNewline -BackgroundColor $s.BeforeBackgroundColor -ForegroundColor $s.BeforeForegroundColor
Write-Host $status.Branch -NoNewline -BackgroundColor $branchBg -ForegroundColor $branchFg
if($status.Added) {
Write-Host " +$($status.Added)" -NoNewline -BackgroundColor $s.AddedBackgroundColor -ForegroundColor $s.AddedForegroundColor
}
if($status.Modified) {
Write-Host " ~$($status.Modified)" -NoNewline -BackgroundColor $s.ModifiedBackgroundColor -ForegroundColor $s.ModifiedForegroundColor
}
if($status.Deleted) {
Write-Host " -$($status.Deleted)" -NoNewline -BackgroundColor $s.DeletedBackgroundColor -ForegroundColor $s.DeletedForegroundColor
}
if ($status.Untracked) {
Write-Host " ?$($status.Untracked)" -NoNewline -BackgroundColor $s.UntrackedBackgroundColor -ForegroundColor $s.UntrackedForegroundColor
}
if($status.Missing) {
Write-Host " !$($status.Missing)" -NoNewline -BackgroundColor $s.MissingBackgroundColor -ForegroundColor $s.MissingForegroundColor
}
if($status.Renamed) {
Write-Host " ^$($status.Renamed)" -NoNewline -BackgroundColor $s.RenamedBackgroundColor -ForegroundColor $s.RenamedForegroundColor
}
if($s.ShowTags -and $status.Tags.Length) {
write-host $s.BeforeTagText -NoNewLine
$tagCounter=0
$status.Tags | % {
$color = $s.TagForegroundColor
if($_.Trim() -eq $status.ActiveBookmark) {
$color = $s.BranchForegroundColor
}
write-host $_ -NoNewLine -ForegroundColor $color -BackgroundColor $s.TagBackgroundColor
if($tagCounter -lt ($status.Tags.Length -1)) {
write-host ", " -NoNewLine -ForegroundColor $s.TagSeparatorColor -BackgroundColor $s.TagBackgroundColor
}
$tagCounter++;
}
}
if($s.ShowPatches) {
$patches = Get-MqPatches
if($patches.All.Length) {
write-host $s.BeforePatchText -NoNewLine
$patchCounter = 0
$patches.Applied | % {
write-host $_ -NoNewLine -ForegroundColor $s.AppliedPatchForegroundColor -BackgroundColor $s.AppliedPatchBackgroundColor
if($patchCounter -lt ($patches.All.Length -1)) {
write-host $s.PatchSeparator -NoNewLine -ForegroundColor $s.PatchSeparatorColor
}
$patchCounter++;
}
$patches.Unapplied | % {
write-host $_ -NoNewLine -ForegroundColor $s.UnappliedPatchForegroundColor -BackgroundColor $s.UnappliedPatchBackgroundColor
if($patchCounter -lt ($patches.All.Length -1)) {
write-host $s.PatchSeparator -NoNewLine -ForegroundColor $s.PatchSeparatorColor
}
$patchCounter++;
}
}
}
Write-Host $s.AfterText -NoNewline -BackgroundColor $s.AfterBackgroundColor -ForegroundColor $s.AfterForegroundColor
}
}