From 6e5c3ca85faa164466ec3521150ed4717a4182f1 Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Sat, 7 Jan 2017 18:46:05 -0700 Subject: [PATCH] WIP allow prompt char > to reflect nesting level. To be a good prompt citizen in PowerShell, the > (or whatever prompt char) should be displayed once for nesting level 0, twice for nesting level 1, and so on. In order to make that happen, we have to allow for deferred expansion of the Prompt*Suffix settings. See https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_prompts for more details. --- GitPrompt.ps1 | 4 ++-- README.md | 1 + posh-git.psm1 | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/GitPrompt.ps1 b/GitPrompt.ps1 index 215f4524b..550dc2b4b 100644 --- a/GitPrompt.ps1 +++ b/GitPrompt.ps1 @@ -96,8 +96,8 @@ $global:GitPromptSettings = New-Object PSObject -Property @{ EnableWindowTitle = 'posh~git ~ ' - PromptSuffix = '> ' - PromptDebugSuffix = ' [DBG]>> ' + PromptSuffix = '$(''>'' * ($nestedPromptLevel + 1)) ' + PromptDebugSuffix = ' [DBG]$(''>'' * ($nestedPromptLevel + 1)) ' Debug = $false diff --git a/README.md b/README.md index 0bce742a0..c4e824599 100644 --- a/README.md +++ b/README.md @@ -225,6 +225,7 @@ This gives us a prompt with a current path that is never greater than 40 charact [rkeithhill/more-readme-tweaks +0 ~1 -0 | +0 ~1 -0 !] ...sers\Keith\GitHub\rkeithhill\posh-git > _ ``` +For more in-depth information on PowerShell prompts, see the online PowerShell help topic [about_prompts](https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_prompts). ## Git Status Summary Information The Git status summary information provides a wealth of "Git status" information at a glance, all the time in your prompt. diff --git a/posh-git.psm1 b/posh-git.psm1 index b4120c73a..b03098d40 100644 --- a/posh-git.psm1 +++ b/posh-git.psm1 @@ -38,7 +38,7 @@ $poshGitPromptScriptBlock = $null $currentPromptDef = if ($funcInfo = Get-Command prompt -ErrorAction SilentlyContinue) { $funcInfo.Definition } -# HACK: If prompt is missing, create a global one we can overwrite with Set-Item +# HACK: If prompt is missing, create a global one we can overwrite with Set-Item if (!$currentPromptDef) { function global:prompt { ' ' } } @@ -85,7 +85,7 @@ if (!$currentPromptDef -or ($currentPromptDef -eq $defaultPromptDef)) { } $global:LASTEXITCODE = $origLastExitCode - $promptSuffix + $ExecutionContext.SessionState.InvokeCommand.ExpandString($promptSuffix) '@) # Set the posh-git prompt as the default prompt