Replace Cmder prompt with custom prompt
This commit is contained in:
parent
cc02ed0914
commit
b8976a84a8
39
profile.ps1
39
profile.ps1
@ -1,9 +1,44 @@
|
||||
# Use Cmder's multiline prompt and posh-git.
|
||||
Import-Module "$env:ChocolateyToolsLocation\Cmder\vendor\profile.ps1"
|
||||
# Enable Git completions & prompt.
|
||||
Import-Module Posh-Git
|
||||
$GitPromptSettings.EnableFileStatus = $false
|
||||
$GitPromptSettings.DefaultPromptPath = ""
|
||||
$GitPromptSettings.DefaultPromptPrefix.Text = ""
|
||||
$GitPromptSettings.DefaultPromptSuffix.Text = ""
|
||||
$GitPromptSettings.BeforeStatus = ""
|
||||
$GitPromptSettings.AfterStatus = ""
|
||||
# Enable Chocolatey completions.
|
||||
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
|
||||
# Enable op completions.
|
||||
Import-Module "$env:LOCALAPPDATA\1Password\cli\opProfile.psm1"
|
||||
# Enable gh completions.
|
||||
Invoke-Expression -Command $(gh completion -s powershell | Out-String)
|
||||
|
||||
# Customize PowerShell prompt.
|
||||
function Prompt {
|
||||
$exitCode = $LastExitCode
|
||||
# Line one
|
||||
Get-Date -Format "HH:mm:ss " | Write-Host -ForegroundColor DarkGray -NoNewline
|
||||
$location = (Get-Location).Path
|
||||
if ($location.StartsWith($env:USERPROFILE)) {
|
||||
$location = $location.Replace($env:USERPROFILE, "~")
|
||||
}
|
||||
$location | Write-Host -ForegroundColor DarkCyan -NoNewline
|
||||
if ($exitCode -ne 0) {
|
||||
" $exitCode" | Write-Host -ForegroundColor DarkRed -NoNewline
|
||||
}
|
||||
& $GitPromptScriptBlock | Write-Host -NoNewline
|
||||
Write-Host
|
||||
# Line two
|
||||
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$principal = [Security.Principal.WindowsPrincipal] $identity
|
||||
$adminRole = [Security.Principal.WindowsBuiltInRole]::Administrator
|
||||
if($principal.IsInRole($adminRole)) {
|
||||
$Env:USERNAME | Write-Host -ForegroundColor DarkRed -NoNewline
|
||||
} else {
|
||||
$Env:USERNAME | Write-Host -ForegroundColor DarkGreen -NoNewline
|
||||
}
|
||||
return ' '
|
||||
}
|
||||
|
||||
# Set UTF-8 as the character set for pipes and output objects.
|
||||
# https://gist.github.com/xoner/4671514
|
||||
|
Loading…
x
Reference in New Issue
Block a user