-
Notifications
You must be signed in to change notification settings - Fork 0
/
customPS.txt
61 lines (50 loc) · 1.95 KB
/
customPS.txt
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
$foregroundColor = 'white'
$foregroundColor2 = 'white'
$time = Get-Date -format r
$psVersion= $host.Version
$curUser= (Get-ChildItem Env:\USERNAME).Value
$curComp= (Get-ChildItem Env:\COMPUTERNAME).Value
Write-Host "Howdy, $curUser!" -foregroundColor $foregroundColor
Write-Host "Today's date is:" $time -foregroundColor $foregroundColor
Write-Host "You're running PowerShell version: $psVersion" -foregroundColor Green
Write-Host "Your computer name is: $curComp" -foregroundColor Green
Write-Host "Happy coding!" `n -foregroundColor $foregroundColor
#function for checking branches
function Write-BranchName () {
try {
$branch = git rev-parse --abbrev-ref HEAD
if ($branch -eq "HEAD") {
# we're probably in detached HEAD state, so print the SHA
$branch = git rev-parse --short HEAD
Write-Host " ($branch)" -ForegroundColor "red"
}
else {
# we're on an actual branch, so print it
Write-Host " ($branch)" -ForegroundColor "blue"
}
} catch {
# we'll end up here if we're in a newly initiated git repo
Write-Host " (no branches yet)" -ForegroundColor "yellow"
}
}
function Prompt {
$curtime = Get-Date
$curDir = Get-Location
Write-Host -NoNewLine "$curUser" -foregroundColor $foregroundColor
Write-Host -NoNewLine "$" -foregroundColor Green
Write-Host -NoNewLine "roglic" `n -foregroundColor $foregroundColor
$path = "$($executionContext.SessionState.Path.CurrentLocation)"
$userPrompt = "$('>' * ($nestedPromptLevel + 1)) "
Write-Host -NoNewline
if (Test-Path .git) {
Write-Host $path -NoNewline -ForegroundColor $foregroundColor2
Write-BranchName
}
else {
# we're not in a repo so don't bother displaying branch name/sha
Write-Host $path -ForegroundColor $foregroundColor2
}
return $userPrompt
}
$host.UI.RawUI.WindowTitle = "PS >> User: $curUser >> Current DIR: $((Get-Location).Path)"
Return " "