-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicrosoft.PowerShell_profile.ps1
43 lines (36 loc) · 1.06 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
[Console]::OutputEncoding = [Text.Encoding]::UTF8
function prompt
{
$currentUser = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent())
$isAdmin = ($currentUser.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
if ($isAdmin)
{
$admin = 'Admin'
$host.UI.RawUI.ForegroundColor = 'Red'
}
else
{
$admin = 'Non-Admin'
}
$host.UI.RawUI.WindowTitle = "$($PSVersionTable.PSEdition) $admin"
}
# define list of aliases
$aliases = @{
sel = "Select-Object"
}
foreach ($alias in $aliases.GetEnumerator())
{
Set-Alias -Name $alias.Key -Value $alias.Value
}
# load additional profile scripts
$profile_scripts = Get-ChildItem -Path "$PSScriptRoot\*_profile.ps1" -Exclude 'Microsoft.PowerShell_profile.ps1'
foreach ($script in $profile_scripts)
{
Write-Host "Loading profile script $script" -ForegroundColor Yellow
. $script
}
# change directory to ONEDRIVE/Code folder
if ($null -eq (Get-Item ENV:VSCODE*))
{
Set-Location "$($env:OneDriveCommercial)\Code"
}