forked from ilude/WindowsPowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.ps1
More file actions
79 lines (61 loc) · 1.8 KB
/
profile.ps1
File metadata and controls
79 lines (61 loc) · 1.8 KB
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
# Directory where this file is located
$script:pwd = Split-Path $MyInvocation.MyCommand.Path
$paths = Join-Path $pwd paths.txt
if(Test-Path $paths) {
Get-Content $paths | foreach {
if(Test-Path $_) {
$env:Path = $env:Path + ";" + $_
}
}
}
###########################
#
# Load all modules
#
###########################
Get-ChildItem $pwd *.psm1 | foreach {
Import-Module $_.VersionInfo.FileName -DisableNameChecking -verbose:$false
}
###########################
#
# Setup prompt
#
###########################
function prompt {
$realLASTEXITCODE = $LASTEXITCODE
$path = ([string]$pwd)
$index = $path.LastIndexOf('\') + 1
$userLocation = $path.Substring($index, $path.Length - $index)
Write-Host($userLocation) -nonewline -foregroundcolor Green
if (Test-GitRepository) {
$branch = Get-GitBranch
Write-Host '[' -nonewline -foregroundcolor Yellow
Write-Host $branch -nonewline -foregroundcolor Cyan
Write-Host ']' -nonewline -foregroundcolor Yellow
$host.UI.RawUi.WindowTitle = "Git:$userLocation - $pwd"
}
else {
$host.UI.RawUi.WindowTitle = "$userLocation - $pwd"
}
$LASTEXITCODE = $realLASTEXITCODE
return "> "
}
###########################
#
# Setup Tab Expansion
#
###########################
$defaul_tab_expansion = 'Default_Tab_Expansion'
if(!(Test-Path Function:\$defaul_tab_expansion)) {
Rename-Item Function:\TabExpansion $defaul_tab_expansion
}
function TabExpansion($line, $lastWord) {
$lastBlock = [regex]::Split($line, '[|;]')[-1].TrimStart()
switch -regex ($lastBlock) {
# Execute git tab completion for all git-related commands
"$(Get-GitAliasPattern) (.*)" { GitTabExpansion $lastBlock }
# Fall back on existing tab expansion
default { & $defaul_tab_expansion $line $lastWord }
}
}
Check-RemoteRepository $pwd -verbose