Created
October 3, 2016 19:47
-
-
Save cdhunt/00a6f98b9d7773b2610bdc6d490ad217 to your computer and use it in GitHub Desktop.
Create and set a random "Session Name" in the PowerShell Console Title
This file contains hidden or 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
Import-Module posh-git | |
Import-Module NameIt | |
function Test-Administrator { | |
return ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") | |
} | |
##### Console Title ###### | |
$SessionTitleName = Invoke-Generate '[Adjective][Noun]' | |
if (Test-Administrator) { | |
$SessionTitle = 'Administrator: PowerShell <' + $SessionTitleName + '>' | |
} | |
else | |
{ | |
$SessionTitle = 'PowerShell <' + $SessionTitleName + '>' | |
} | |
$Host.UI.RawUI.WindowTitle = $SessionTitle | |
$Global:GitPromptSettings.EnableWindowTitle = "posh~git ~ <$SessionTitleName>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment