Functions/Prompt/Enable-Prompt.ps1
<# .SYNOPSIS Enable the custom prompt. .DESCRIPTION Enable the custom prompt provided by this module. It will show an indicator if the shell is startet as admin (red) or normal user (yellow). .INPUTS None. .OUTPUTS None. .EXAMPLE Enable-Prompt Enable the custom prompt. .NOTES Author : Claudio Spizzi License : MIT License .LINK https://github.com/claudiospizzi/Spizzi.Profile #> function Enable-Prompt { [CmdletBinding()] param ( ) $IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) New-Variable -Scope Global -Name PromptColor -Value $(if($IsAdmin) { 'Red' } else { 'Yellow' }) -Force New-Variable -Scope Global -Name PromptGit -Value $false -Force function Global:Prompt { $Host.UI.Write($Global:PromptColor, $Host.UI.RawUI.BackgroundColor, '[PS]') $Host.UI.Write(" $($ExecutionContext.SessionState.Path.CurrentLocation)") if ($Global:PromptGit) { Write-VcsStatus } return "$('>' * ($NestedPromptLevel + 1)) " } } |