Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 99 lines (78 sloc) 4.168 kB
8e6e8a6 @JeremySkinner Added separate settings file. Basic PBranch integration.
authored
1 # For backwards compatibility
2 $global:HgPromptSettings = $global:PoshHgSettings
ddf6f33 @JeremySkinner Fixing line endings - autocrlf is now set to false
authored
3
70ddcce @JeremySkinner Added support for tags
authored
4 function Write-HgStatus($status = (get-hgStatus)) {
ddf6f33 @JeremySkinner Fixing line endings - autocrlf is now set to false
authored
5 if ($status) {
8e6e8a6 @JeremySkinner Added separate settings file. Basic PBranch integration.
authored
6 $s = $global:PoshHgSettings
ddf6f33 @JeremySkinner Fixing line endings - autocrlf is now set to false
authored
7
c3016e7 @JeremySkinner Prompt colouring detects when you're not up to date
authored
8 $branchFg = $s.BranchForegroundColor
9 $branchBg = $s.BranchBackgroundColor
10
11 if($status.Behind) {
12 $branchFg = $s.Branch2ForegroundColor
13 $branchBg = $s.Branch2BackgroundColor
14 }
15
ddf6f33 @JeremySkinner Fixing line endings - autocrlf is now set to false
authored
16 Write-Host $s.BeforeText -NoNewline -BackgroundColor $s.BeforeBackgroundColor -ForegroundColor $s.BeforeForegroundColor
c3016e7 @JeremySkinner Prompt colouring detects when you're not up to date
authored
17 Write-Host $status.Branch -NoNewline -BackgroundColor $branchBg -ForegroundColor $branchFg
ddf6f33 @JeremySkinner Fixing line endings - autocrlf is now set to false
authored
18
19 if($status.Added) {
8d847bf @rstuven Added color settings per status. Default values are the same of Mercu…
rstuven authored
20 Write-Host " +$($status.Added)" -NoNewline -BackgroundColor $s.AddedBackgroundColor -ForegroundColor $s.AddedForegroundColor
ddf6f33 @JeremySkinner Fixing line endings - autocrlf is now set to false
authored
21 }
22 if($status.Modified) {
8d847bf @rstuven Added color settings per status. Default values are the same of Mercu…
rstuven authored
23 Write-Host " ~$($status.Modified)" -NoNewline -BackgroundColor $s.ModifiedBackgroundColor -ForegroundColor $s.ModifiedForegroundColor
ddf6f33 @JeremySkinner Fixing line endings - autocrlf is now set to false
authored
24 }
25 if($status.Deleted) {
8d847bf @rstuven Added color settings per status. Default values are the same of Mercu…
rstuven authored
26 Write-Host " -$($status.Deleted)" -NoNewline -BackgroundColor $s.DeletedBackgroundColor -ForegroundColor $s.DeletedForegroundColor
ddf6f33 @JeremySkinner Fixing line endings - autocrlf is now set to false
authored
27 }
28
29 if ($status.Untracked) {
8d847bf @rstuven Added color settings per status. Default values are the same of Mercu…
rstuven authored
30 Write-Host " ?$($status.Untracked)" -NoNewline -BackgroundColor $s.UntrackedBackgroundColor -ForegroundColor $s.UntrackedForegroundColor
ddf6f33 @JeremySkinner Fixing line endings - autocrlf is now set to false
authored
31 }
32
33 if($status.Missing) {
8d847bf @rstuven Added color settings per status. Default values are the same of Mercu…
rstuven authored
34 Write-Host " !$($status.Missing)" -NoNewline -BackgroundColor $s.MissingBackgroundColor -ForegroundColor $s.MissingForegroundColor
ddf6f33 @JeremySkinner Fixing line endings - autocrlf is now set to false
authored
35 }
599b4e6 @JeremySkinner Support empty tags
authored
36
df05530 @vcaraulean Added support for 'Renamed' file status
vcaraulean authored
37 if($status.Renamed) {
8d847bf @rstuven Added color settings per status. Default values are the same of Mercu…
rstuven authored
38 Write-Host " ^$($status.Renamed)" -NoNewline -BackgroundColor $s.RenamedBackgroundColor -ForegroundColor $s.RenamedForegroundColor
df05530 @vcaraulean Added support for 'Renamed' file status
vcaraulean authored
39 }
40
599b4e6 @JeremySkinner Support empty tags
authored
41 if($s.ShowTags -and $status.Tags.Length) {
70ddcce @JeremySkinner Added support for tags
authored
42 write-host $s.BeforeTagText -NoNewLine
756c8d2 @matthewrfindley Modified tab extension and prompt to support bookmarks
matthewrfindley authored
43
70ddcce @JeremySkinner Added support for tags
authored
44 $tagCounter=0
45 $status.Tags | % {
756c8d2 @matthewrfindley Modified tab extension and prompt to support bookmarks
matthewrfindley authored
46 $color = $s.TagForegroundColor
47
48 if($_.Trim() -eq $status.ActiveBookmark) {
49 $color = $s.BranchForegroundColor
50 }
51
52 write-host $_ -NoNewLine -ForegroundColor $color -BackgroundColor $s.TagBackgroundColor
53
70ddcce @JeremySkinner Added support for tags
authored
54 if($tagCounter -lt ($status.Tags.Length -1)) {
55 write-host ", " -NoNewLine -ForegroundColor $s.TagSeparatorColor -BackgroundColor $s.TagBackgroundColor
56 }
57 $tagCounter++;
58 }
59 }
60
8fe663f @JeremySkinner Adding MQ prompt integration. Tab expansion to follow
authored
61 if($s.ShowPatches) {
62 $patches = Get-MqPatches
63 if($patches.All.Length) {
64 write-host $s.BeforePatchText -NoNewLine
65
66 $patchCounter = 0
67
68 $patches.Applied | % {
69 write-host $_ -NoNewLine -ForegroundColor $s.AppliedPatchForegroundColor -BackgroundColor $s.AppliedPatchBackgroundColor
70 if($patchCounter -lt ($patches.All.Length -1)) {
71 write-host $s.PatchSeparator -NoNewLine -ForegroundColor $s.PatchSeparatorColor
72 }
73 $patchCounter++;
74 }
75
76 $patches.Unapplied | % {
77 write-host $_ -NoNewLine -ForegroundColor $s.UnappliedPatchForegroundColor -BackgroundColor $s.UnappliedPatchBackgroundColor
78 if($patchCounter -lt ($patches.All.Length -1)) {
79 write-host $s.PatchSeparator -NoNewLine -ForegroundColor $s.PatchSeparatorColor
80 }
81 $patchCounter++;
82 }
83 }
84 }
85
70ddcce @JeremySkinner Added support for tags
authored
86 Write-Host $s.AfterText -NoNewline -BackgroundColor $s.AfterBackgroundColor -ForegroundColor $s.AfterForegroundColor
ddf6f33 @JeremySkinner Fixing line endings - autocrlf is now set to false
authored
87 }
663e3f3 @dahlbyk Add Write-VcsStatus to easily support multiple VCS prompts
dahlbyk authored
88 }
89
90 # Should match https://github.com/dahlbyk/posh-git/blob/master/GitPrompt.ps1
91 if (!$Global:VcsPromptStatuses) { $Global:VcsPromptStatuses = @() }
92 function Global:Write-VcsStatus { $Global:VcsPromptStatuses | foreach { & $_ } }
93
94 # Add scriptblock that will execute for Write-VcsStatus
95 $Global:VcsPromptStatuses += {
96 $Global:HgStatus = Get-HgStatus
97 Write-HgStatus $HgStatus
98 }
Something went wrong with that request. Please try again.