-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPrompt.ps1
More file actions
51 lines (44 loc) · 2.15 KB
/
Prompt.ps1
File metadata and controls
51 lines (44 loc) · 2.15 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
function Prompt
{
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Rikard Ronnkvist / snowland.se
# Multicolored prompt with marker for windows started as Admin and marker for providers outside filesystem
# Examples
# C:\Windows\System32>
# [Admin] C:\Windows\System32>
# [Registry] HKLM:\SOFTWARE\Microsoft\Windows>
# [Admin] [Registry] HKLM:\SOFTWARE\Microsoft\Windows>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# New nice WindowTitle
$Host.UI.RawUI.WindowTitle = "PowerShell v" + (get-host).Version.Major + "." + (get-host).Version.Minor + " (" + $pwd.Provider.Name + ") " + $pwd.Path
# Admin ?
if( (
New-Object Security.Principal.WindowsPrincipal (
[Security.Principal.WindowsIdentity]::GetCurrent())
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
# Admin-mark in WindowTitle
$Host.UI.RawUI.WindowTitle = "[Admin] " + $Host.UI.RawUI.WindowTitle
# Admin-mark on prompt
Write-Host "[" -nonewline -foregroundcolor DarkGray
Write-Host "Admin" -nonewline -foregroundcolor Red
Write-Host "] " -nonewline -foregroundcolor DarkGray
}
# Show providername if you are outside FileSystem
if ($pwd.Provider.Name -ne "FileSystem") {
Write-Host "[" -nonewline -foregroundcolor DarkGray
#Write-Host $pwd.Provider.Name -nonewline -foregroundcolor Gray
Write-Host $pwd.Provider.Name -nonewline -foregroundcolor DarkGray
Write-Host "] " -nonewline -foregroundcolor DarkGray
}
# Split path and write \ in a gray
$pwd.Path.Split("\") | foreach {
Write-Host $_ -nonewline -foregroundcolor Yellow
#Write-Host "\" -nonewline -foregroundcolor Gray
Write-Host "\" -nonewline -foregroundcolor DarkGray
}
# Backspace last \ and write >
#Write-Host "`b>" -nonewline -foregroundcolor Gray
Write-Host "`b>" -nonewline -foregroundcolor DarkGray
return " "
}