Last active
October 21, 2017 20:21
-
-
Save jimfrenette/2995bdfa7dc531db1478692112c72bc9 to your computer and use it in GitHub Desktop.
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
# http://serverfault.com/questions/95431 | |
function Test-Administrator { | |
$user = [Security.Principal.WindowsIdentity]::GetCurrent(); | |
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | |
} | |
function prompt { | |
# https://github.com/dahlbyk/posh-git/wiki/Customizing-Your-PowerShell-Prompt | |
$origLastExitCode = $LastExitCode | |
Write-VcsStatus | |
if (Test-Administrator) { # if elevated | |
Write-Host "(Elevated) " -NoNewline -ForegroundColor White | |
} | |
Write-Host "$env:USERNAME@" -NoNewline -ForegroundColor DarkYellow | |
Write-Host "$env:COMPUTERNAME" -NoNewline -ForegroundColor Magenta | |
Write-Host ": " -NoNewline -ForegroundColor DarkGray | |
$curPath = $ExecutionContext.SessionState.Path.CurrentLocation.Path | |
if ($curPath.ToLower().StartsWith($Home.ToLower())) | |
{ | |
$curPath = "~" + $curPath.SubString($Home.Length) | |
} | |
Write-Host $curPath -NoNewline -ForegroundColor Green | |
$LastExitCode = $origLastExitCode | |
"`n$('>' * ($nestedPromptLevel + 1)) " | |
} | |
Import-Module PSReadLine | |
Set-PSReadLineOption -HistoryNoDuplicates | |
Set-PSReadLineOption -HistorySearchCursorMovesToEnd | |
Set-PSReadLineOption -HistorySaveStyle SaveIncrementally | |
Set-PSReadLineOption -MaximumHistoryCount 4000 | |
# history substring search | |
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward | |
# Tab completion | |
Set-PSReadlineKeyHandler -Chord 'Shift+Tab' -Function Complete | |
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete | |
Import-Module Get-ChildItemColor | |
Set-Alias l Get-ChildItemColor -option AllScope | |
Set-Alias ls Get-ChildItemColorFormatWide -option AllScope | |
Import-Module posh-git | |
$global:GitPromptSettings.BeforeText = '[' | |
$global:GitPromptSettings.AfterText = '] ' | |
# Update path for SSH (Loaded in PowerShell Profile) | |
$env:path += ";" + (Get-Item "Env:ProgramFiles").Value + "\Git\bin" | |
$env:path += ";" + (Get-Item "Env:ProgramFiles").Value + "\Git\usr\bin" | |
# Load SSH agent utils | |
. (Resolve-Path ~/Documents/WindowsPowershell/ssh-agent-utils.ps1) | |
Pop-Location | |
Add-SshKey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment