Skip to content

Instantly share code, notes, and snippets.

@breiter
Last active May 25, 2023 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save breiter/38748549a90bf0b6743d to your computer and use it in GitHub Desktop.
Save breiter/38748549a90bf0b6743d to your computer and use it in GitHub Desktop.
profile.ps1
$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"
@breiter
Copy link
Author

breiter commented Aug 28, 2014

Public powershell profile for use in C:\Windows\System32\WindowsPowerShell\v1.0.

  • Marks prompt when running as Administrator
  • Adds an alias for vi to integrate with vi from msysgit.
  • Adds a Utilities directory to the front of the path for dumping scripts and executable utils.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment