-
Notifications
You must be signed in to change notification settings - Fork 12
/
Microsoft.PowerShell_profile.ps1
108 lines (94 loc) · 3.94 KB
/
Microsoft.PowerShell_profile.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
####################### Importing the PSReadline module
Import-Module PSReadline
function prompt {
$origLastExitCode = $LastExitCode
$curPath = $ExecutionContext.SessionState.Path.CurrentLocation.Path
if ($curPath.ToLower().StartsWith($Home.ToLower())) {
$curPath = "~" + $curPath.SubString($Home.Length)
}
Write-Host $curPath -NoNewline -ForegroundColor Black -BackgroundColor DarkGreen
Write-Host "$([char]57520) " -NoNewline -ForegroundColor DarkGreen
Write-VcsStatus
"`n$('>' * ($nestedPromptLevel + 1)) "
$LastExitCode = $origLastExitCode
}
####################### Posh-Git
Import-Module -Name 'posh-git'
# Background colors
$baseBackgroundColor = 'DarkBlue'
$GitPromptSettings.AfterStashBackgroundColor = $baseBackgroundColor
$GitPromptSettings.BeforeBackgroundColor = $baseBackgroundColor
$GitPromptSettings.BeforeIndexBackgroundColor = $baseBackgroundColor
$GitPromptSettings.BeforeStashBackgroundColor = $baseBackgroundColor
$GitPromptSettings.BranchAheadStatusBackgroundColor = $baseBackgroundColor
$GitPromptSettings.BranchBackgroundColor = $baseBackgroundColor
$GitPromptSettings.BranchBehindAndAheadStatusBackgroundColor = $baseBackgroundColor
$GitPromptSettings.BranchBehindStatusBackgroundColor = $baseBackgroundColor
$GitPromptSettings.BranchGoneStatusBackgroundColor = $baseBackgroundColor
$GitPromptSettings.BranchIdenticalStatusToBackgroundColor = $baseBackgroundColor
$GitPromptSettings.DelimBackgroundColor = $baseBackgroundColor
$GitPromptSettings.IndexBackgroundColor = $baseBackgroundColor
$GitPromptSettings.ErrorBackgroundColor = $baseBackgroundColor
$GitPromptSettings.LocalDefaultStatusBackgroundColor = $baseBackgroundColor
$GitPromptSettings.LocalStagedStatusBackgroundColor = $baseBackgroundColor
$GitPromptSettings.LocalWorkingStatusBackgroundColor = $baseBackgroundColor
$GitPromptSettings.StashBackgroundColor = $baseBackgroundColor
$GitPromptSettings.WorkingBackgroundColor = $baseBackgroundColor
# Foreground colors
$GitPromptSettings.AfterForegroundColor = $baseBackgroundColor
$GitPromptSettings.BeforeForegroundColor = "Black"
$GitPromptSettings.BranchForegroundColor = "Blue"
$GitPromptSettings.BranchGoneStatusForegroundColor = "Blue"
$GitPromptSettings.BranchIdenticalStatusToForegroundColor = "DarkYellow"
$GitPromptSettings.DefaultForegroundColor = "Gray"
$GitPromptSettings.DelimForegroundColor = "Blue"
$GitPromptSettings.IndexForegroundColor = "Green"
#$GitPromptSettings.WorkingForegroundColor = "Yellow"
# Prompt shape
$GitPromptSettings.BeforeText = "$([char]57520)"
$GitPromptSettings.AfterText = "$([char]57520) "
$GitPromptSettings.DelimText = " ॥"
$GitPromptSettings.ShowStatusWhenZero = $False
function Get-FullHelp {
[cmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$cmd
)
If ((Get-Command -Name $cmd).CommandType -eq "Cmdlet" ) {
$cmdlet = (Get-Command -Name $cmd).Name
}
Elseif ((Get-Command -Name $cmd).CommandType -eq "Function" ) {
$cmdlet = (Get-Command -Name $cmd).Name
}
Elseif ((Get-Command -Name $cmd).CommandType -eq "Alias" ) {
# Resolving aliases to cmdlet names
$cmdlet = (Get-Command -Name $cmd).Definition
}
Else {
# No support for other command types, like workflows, external commands and external scripts
throw "Could not resolve $cmd to a valid Cmdlet name. Exiting the function."
} # End conditional statements
Get-Help $cmdlet -Full | more
}
######################### Setting an alias for the function Get-FullHelp
New-Alias -Name gfh -Value Get-FullHelp
######################## Aliases for common git commands
function gpo {
& git push origin master
}
function gpr {
& git pull --rebase
}
function gpc {
& git commit -m $args
}
function ga {
& git add --all
}
function gst {
& git status
}
function glp {
& git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %C(bold green)(%cr) %C(bold yellow)<%an>%Creset' --abbrev-commit
}