Last active
September 30, 2020 07:28
-
-
Save SeanSobey/f515ba6d0d0bd72d4bbc35b56a094341 to your computer and use it in GitHub Desktop.
Powershell profile, see here: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7
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
# https://joonro.github.io/blog/posts/powershell-customizations.html | |
# https://hodgkins.io/ultimate-powershell-prompt-and-git-setup | |
Import-Module posh-docker | |
Write-Host "Imported posh-docker" | |
# https://github.com/dahlbyk/posh-git | |
Import-Module posh-git | |
Write-Host "Imported posh-git" | |
$global:GitPromptSettings.BeforeText = '[' | |
$global:GitPromptSettings.AfterText = '] ' | |
$global:GitPromptSettings.EnableWindowTitle = '' | |
# https://github.com/lzybkr/PSReadLine | |
Import-Module PSReadLine | |
Write-Host "Imported PSReadLine" | |
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward | |
Set-PSReadlineKeyHandler -Chord 'Shift+Tab' -Function Complete | |
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete | |
# https://github.com/JannesMeyer/z.ps | |
Import-Module z | |
Set-Alias z Search-NavigationHistory -Scope Global | |
Write-Host "Imported z" | |
# Chocolatey profile | |
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
if (Test-Path($ChocolateyProfile)) { | |
Import-Module "$ChocolateyProfile" | |
Write-Host "Imported Chocolatey Profile" | |
} | |
# Start-SshAgent | |
# Write-Host "Started SshAgent" | |
# 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 | |
$prompt = "" | |
$spacer = " " # " : " | |
$curPath = $ExecutionContext.SessionState.Path.CurrentLocation.Path | |
$prompt += Write-Prompt (Get-Date -Format G) -NoNewline -ForegroundColor DarkGreen # Date | |
$prompt += Write-Prompt $spacer -NoNewline -ForegroundColor DarkGray | |
if (Test-Administrator) { # if elevated | |
$prompt += Write-Prompt "(Elevated)" -NoNewline -ForegroundColor White | |
} | |
else { | |
$prompt += Write-Prompt "(Not-Elevated)" -NoNewline -ForegroundColor White | |
} | |
$prompt += Write-Prompt $spacer -NoNewline -ForegroundColor DarkGray | |
$prompt += Write-Prompt "$env:USERNAME@" -NoNewline -ForegroundColor DarkYellow | |
$prompt += Write-Prompt "$env:COMPUTERNAME" -NoNewline -ForegroundColor Magenta | |
$prompt += Write-Prompt $spacer -NoNewline -ForegroundColor DarkGray | |
$prompt += Write-VcsStatus # Posh-Git | |
$prompt += Write-Prompt $spacer -NoNewline -ForegroundColor DarkGray | |
# if ($curPath.ToLower().StartsWith($Home.ToLower())) {# Path | |
# $prompt += Write-Prompt "~" + $curPath.SubString($Home.Length) -NoNewline -ForegroundColor Blue | |
# } else { | |
$prompt += Write-Prompt $curPath -NoNewline -ForegroundColor Blue | |
# } | |
$prompt += "`n$('>' * ($nestedPromptLevel + 1)) " | |
$LastExitCode = $origLastExitCode | |
Update-NavigationHistory $pwd.Path | |
$prompt | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment