Skip to content

Instantly share code, notes, and snippets.

@cdhunt
Created October 3, 2016 19:47
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 cdhunt/00a6f98b9d7773b2610bdc6d490ad217 to your computer and use it in GitHub Desktop.
Save cdhunt/00a6f98b9d7773b2610bdc6d490ad217 to your computer and use it in GitHub Desktop.
Create and set a random "Session Name" in the PowerShell Console Title
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