Last active
May 25, 2023 07:07
-
-
Save breiter/38748549a90bf0b6743d to your computer and use it in GitHub Desktop.
profile.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal( [Security.Principal.WindowsIdentity]::GetCurrent() ) | |
$administrator = $currentPrincipal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator ) | |
$progfilesx86 = $env:programfiles | |
$is64bitenv = $false; | |
#System.IntPtr is 64 bits on x64 and 32 bits on x86 | |
$is64bitenv = [IntPtr]::size * 8 -eq 64; | |
$progfilesx86 = $env:programfiles | |
if( $is64bitenv ) | |
{ | |
$progfilesx86 = $(get-childitem 'env:\programfiles(x86)').Value | |
} | |
& { | |
if ( $administrator ) | |
{ | |
#(get-host).UI.RawUI.Backgroundcolor="DarkRed" | |
#clear-host | |
write-host "Warning: PowerShell is running as an Administrator.`n" | |
} | |
if( $is64bitenv ) | |
{ | |
$host.UI.RawUI.WindowTitle = "Windows PowerShell (x64)" | |
} | |
else | |
{ | |
$host.UI.RawUI.WindowTitle = "Windows PowerShell (x86)" | |
} | |
$utilities = "$progfilesx86\Utilities" | |
if( (Test-Path $utilities) -and !($env:path -match $utilities.Replace("\","\\")) ) | |
{ | |
$env:path = "$utilities;${env:path}" | |
} | |
} | |
function Prompt | |
{ | |
if ( $administrator ) | |
{ | |
if( !$host.UI.RawUI.WindowTitle.StartsWith( "Administrator: " ) ) | |
{ $Host.UI.RawUI.WindowTitle = "Administrator: " + $host.UI.RawUI.WindowTitle } | |
'Administrator: PS' + $(if ($nestedpromptlevel -ge 1) { '>>' }) + '> ' | |
} | |
else | |
{ 'PS' + $(if ($nestedpromptlevel -ge 1) { '>>' }) + '> ' } | |
} | |
new-alias vi "$progfilesx86\git\share\vim\vim74\vim.exe" | |
new-alias vim "$progfilesx86\git\share\vim\vim74\vim.exe" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Public powershell profile for use in C:\Windows\System32\WindowsPowerShell\v1.0.