From b4122c0401feaf1c37249cec98e134cfd19d1bed Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Sun, 20 Aug 2023 13:28:04 -0500 Subject: [PATCH 1/3] Document new TerminateOrphanedConsoleApps switch --- .../7.4/PSReadLine/Get-PSReadLineOption.md | 30 +++++++++++------- .../7.4/PSReadLine/Set-PSReadLineOption.md | 31 +++++++++++++++++-- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/reference/7.4/PSReadLine/Get-PSReadLineOption.md b/reference/7.4/PSReadLine/Get-PSReadLineOption.md index ad3417b858ca..c7438e49ec36 100644 --- a/reference/7.4/PSReadLine/Get-PSReadLineOption.md +++ b/reference/7.4/PSReadLine/Get-PSReadLineOption.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.PSReadLine2.dll-Help.xml Locale: en-US Module Name: PSReadLine -ms.date: 12/13/2022 +ms.date: 08/20/2023 online version: https://learn.microsoft.com/powershell/module/psreadline/get-psreadlineoption?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: Get-PSReadLineOption @@ -44,35 +44,43 @@ HistorySaveStyle : SaveIncrementally HistorySearchCaseSensitive : False HistorySearchCursorMovesToEnd : False MaximumHistoryCount : 4096 -ContinuationPrompt : >> +ContinuationPrompt : ExtraPromptLineCount : 0 -PromptText : {> } +PromptText : BellStyle : Audible DingDuration : 50 DingTone : 1221 -CommandsToValidateScriptBlockArguments : {ForEach-Object, %, Invoke-Command, icm...} +CommandsToValidateScriptBlockArguments : {ForEach-Object, %, Invoke-Command, icm…} CommandValidationHandler : CompletionQueryItems : 100 MaximumKillRingCount : 10 ShowToolTips : True ViModeIndicator : None -WordDelimiters : ;:,.[]{}()/\|^&*-=+'"--- +WordDelimiters : ;:,.[]{}()/\|!?^&*-=+'"–—― AnsiEscapeTimeout : 100 +PredictionSource : HistoryAndPlugin +PredictionViewStyle : InlineView +TerminateOrphanedConsoleApps : False CommandColor : "`e[93m" CommentColor : "`e[32m" -ContinuationPromptColor : "`e[97m" -DefaultTokenColor : "`e[97m" +ContinuationPromptColor : "`e[37m" +DefaultTokenColor : "`e[37m" EmphasisColor : "`e[96m" ErrorColor : "`e[91m" +InlinePredictionColor : "`e[100m" KeywordColor : "`e[92m" -MemberColor : "`e[97m" +ListPredictionColor : "`e[33m" +ListPredictionSelectedColor : "`e[48;5;238m" +ListPredictionTooltipColor : "`e[97;2;3m" +MemberColor : "`e[37m" NumberColor : "`e[97m" -OperatorColor : "`e[90m" -ParameterColor : "`e[90m" -SelectionColor : "`e[30;107m" +OperatorColor : "`e[95m" +ParameterColor : "`e[95m" +SelectionColor : "`e[92m`e[100m" StringColor : "`e[36m" TypeColor : "`e[37m" VariableColor : "`e[92m" + ``` This command returns the list of available PSReadLine options and their current values. diff --git a/reference/7.4/PSReadLine/Set-PSReadLineOption.md b/reference/7.4/PSReadLine/Set-PSReadLineOption.md index 879de2025d82..225f6aa9bb0f 100644 --- a/reference/7.4/PSReadLine/Set-PSReadLineOption.md +++ b/reference/7.4/PSReadLine/Set-PSReadLineOption.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.PSReadLine2.dll-Help.xml Locale: en-US Module Name: PSReadLine -ms.date: 07/19/2023 +ms.date: 08/20/2023 online version: https://learn.microsoft.com/powershell/module/psreadline/set-psreadlineoption?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: Set-PSReadLineOption @@ -25,7 +25,8 @@ Set-PSReadLineOption [-EditMode ] [-ContinuationPrompt ] [-His [-HistorySearchCaseSensitive] [-HistorySaveStyle ] [-HistorySavePath ] [-AnsiEscapeTimeout ] [-PromptText ] [-ViModeIndicator ] [-ViModeChangeHandler ] [-PredictionSource ] - [-PredictionViewStyle ] [-Colors ] [] + [-PredictionViewStyle ] [-Colors ] [-TerminateOrphanedConsoleApps] + [-ProgressAction ] [] ``` ## DESCRIPTION @@ -748,6 +749,32 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -TerminateOrphanedConsoleApps + +This parameter sets the **TerminateOrphanedConsoleApps** option to `$true`. + +On Windows, when you press Ctrl+c to terminate a process, each process +attached to a console receives a terminate signal, as opposed to just the active shell. Sometimes, +when a shell has launched some large tree of child processes, (imagine a build system, for example) +some processes may exit, leaving multiple processes concurrently trying to consume console input. + +When the **TerminateOrphanedConsoleApps** option is set to `$true`, tracks child processes and +properly terminates them after receiving a Ctrl+c signal. + +This parameter and option were added in PSReadLine 2.3.2-beta2. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -ViModeChangeHandler When the **ViModeIndicator** is set to `Script`, the script block provided will be invoked every From 506c19cb4ba31da6541a8ca919b5fed8fd9d874a Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Mon, 21 Aug 2023 12:59:13 -0500 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Dongbo Wang --- reference/7.4/PSReadLine/Get-PSReadLineOption.md | 2 +- reference/7.4/PSReadLine/Set-PSReadLineOption.md | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/reference/7.4/PSReadLine/Get-PSReadLineOption.md b/reference/7.4/PSReadLine/Get-PSReadLineOption.md index c7438e49ec36..44934caa27f1 100644 --- a/reference/7.4/PSReadLine/Get-PSReadLineOption.md +++ b/reference/7.4/PSReadLine/Get-PSReadLineOption.md @@ -67,7 +67,7 @@ ContinuationPromptColor : "`e[37m" DefaultTokenColor : "`e[37m" EmphasisColor : "`e[96m" ErrorColor : "`e[91m" -InlinePredictionColor : "`e[100m" +InlinePredictionColor : "`e[97;2;3m" KeywordColor : "`e[92m" ListPredictionColor : "`e[33m" ListPredictionSelectedColor : "`e[48;5;238m" diff --git a/reference/7.4/PSReadLine/Set-PSReadLineOption.md b/reference/7.4/PSReadLine/Set-PSReadLineOption.md index 225f6aa9bb0f..a33f3c1ebc35 100644 --- a/reference/7.4/PSReadLine/Set-PSReadLineOption.md +++ b/reference/7.4/PSReadLine/Set-PSReadLineOption.md @@ -758,8 +758,7 @@ attached to a console receives a terminate signal, as opposed to just the active when a shell has launched some large tree of child processes, (imagine a build system, for example) some processes may exit, leaving multiple processes concurrently trying to consume console input. -When the **TerminateOrphanedConsoleApps** option is set to `$true`, tracks child processes and -properly terminates them after receiving a Ctrl+c signal. +When setting the **TerminateOrphanedConsoleApps** option to `$true`, PSReadLine records the list of processes that are currently attached to the console. Afterwards, whenever PSReadLine runs, it will get a new list of processes attached to the console, and terminate those that are not in the original list. This parameter and option were added in PSReadLine 2.3.2-beta2. From c632cba9bfe94210485192ff62041c3cf114a20e Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Mon, 21 Aug 2023 13:16:39 -0500 Subject: [PATCH 3/3] Feedback changes --- .../7.4/PSReadLine/Get-PSReadLineOption.md | 10 +++---- .../7.4/PSReadLine/Set-PSReadLineOption.md | 28 +++++++++++-------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/reference/7.4/PSReadLine/Get-PSReadLineOption.md b/reference/7.4/PSReadLine/Get-PSReadLineOption.md index 44934caa27f1..4b261496466d 100644 --- a/reference/7.4/PSReadLine/Get-PSReadLineOption.md +++ b/reference/7.4/PSReadLine/Get-PSReadLineOption.md @@ -44,9 +44,9 @@ HistorySaveStyle : SaveIncrementally HistorySearchCaseSensitive : False HistorySearchCursorMovesToEnd : False MaximumHistoryCount : 4096 -ContinuationPrompt : +ContinuationPrompt : >> ExtraPromptLineCount : 0 -PromptText : +PromptText : > BellStyle : Audible DingDuration : 50 DingTone : 1221 @@ -74,9 +74,9 @@ ListPredictionSelectedColor : "`e[48;5;238m" ListPredictionTooltipColor : "`e[97;2;3m" MemberColor : "`e[37m" NumberColor : "`e[97m" -OperatorColor : "`e[95m" -ParameterColor : "`e[95m" -SelectionColor : "`e[92m`e[100m" +OperatorColor : "`e[90m" +ParameterColor : "`e[90m" +SelectionColor : "`e[30;47m" StringColor : "`e[36m" TypeColor : "`e[37m" VariableColor : "`e[92m" diff --git a/reference/7.4/PSReadLine/Set-PSReadLineOption.md b/reference/7.4/PSReadLine/Set-PSReadLineOption.md index a33f3c1ebc35..7487ae5f25fb 100644 --- a/reference/7.4/PSReadLine/Set-PSReadLineOption.md +++ b/reference/7.4/PSReadLine/Set-PSReadLineOption.md @@ -26,7 +26,7 @@ Set-PSReadLineOption [-EditMode ] [-ContinuationPrompt ] [-His [-AnsiEscapeTimeout ] [-PromptText ] [-ViModeIndicator ] [-ViModeChangeHandler ] [-PredictionSource ] [-PredictionViewStyle ] [-Colors ] [-TerminateOrphanedConsoleApps] - [-ProgressAction ] [] + [] ``` ## DESCRIPTION @@ -209,8 +209,8 @@ Specifies a **ScriptBlock** that controls which commands get added to **PSReadLi The **ScriptBlock** receives the command line as input. -The **ScripBlock** should return a member of the **AddToHistoryOption** enum, the string name of -one of those members, or a boolean value. The list below describes the possible values and their +The **ScripBlock** should return a member of the **AddToHistoryOption** enum, the string name of one +of those members, or a boolean value. The list below describes the possible values and their effects. - `MemoryAndFile` - Add the command to the history file and the current session. @@ -237,8 +237,8 @@ This option is specific to Windows when input is redirected, for example, when r or `screen`. With redirected input on Windows, many keys are sent as a sequence of characters starting with the -escape character. It's impossible to distinguish between a single escape character followed by -more characters and a valid escape sequence. +escape character. It's impossible to distinguish between a single escape character followed by more +characters and a valid escape sequence. The assumption is that the terminal can send the characters faster than a user types. **PSReadLine** waits for this timeout before concluding that it has received a complete escape sequence. @@ -284,7 +284,8 @@ Accept wildcard characters: False The **Colors** parameter specifies various colors used by **PSReadLine**. The argument is a hash table where the keys specify which element and the values specify the color. -For more information, see [about_Hash_Tables](/powershell/module/microsoft.powershell.core/about/about_hash_tables). +For more information, see +[about_Hash_Tables](/powershell/module/microsoft.powershell.core/about/about_hash_tables). Colors can be either a value from **ConsoleColor**, for example `[ConsoleColor]::Red`, or a valid ANSI escape sequence. Valid escape sequences depend on your terminal. In PowerShell 5.0, an example @@ -303,7 +304,8 @@ Two color settings were added to support customization of the `ListView` in PSRe - Foreground, background, or both - Inverse, bold -For more information about ANSI color codes, see [ANSI escape code](https://wikipedia.org/wiki/ANSI_escape_code#Colors_) in Wikipedia. +For more information about ANSI color codes, see the Wikipedia article +[ANSI escape code](https://wikipedia.org/wiki/ANSI_escape_code#Colors_). The valid keys include: @@ -728,10 +730,9 @@ When displaying possible completions, tooltips are shown in the list of completi This option is enabled by default. This option wasn't enabled by default in prior versions of **PSReadLine**. To disable, set this option to `$False`. -By default, the **ShowToolTips** property of the global **PSConsoleReadLineOptions** -object is set to `True`. Using this **SwitchParameter** sets the property value to `True`. To change -the property value, you must specify the value of the **SwitchParameter** as follows: -`-ShowToolTips:$False`. +By default, the **ShowToolTips** property of the global **PSConsoleReadLineOptions** object is set +to `True`. Using this **SwitchParameter** sets the property value to `True`. To change the property +value, you must specify the value of the **SwitchParameter** as follows: `-ShowToolTips:$False`. Using the following command, you can set the property value directly: @@ -758,7 +759,10 @@ attached to a console receives a terminate signal, as opposed to just the active when a shell has launched some large tree of child processes, (imagine a build system, for example) some processes may exit, leaving multiple processes concurrently trying to consume console input. -When setting the **TerminateOrphanedConsoleApps** option to `$true`, PSReadLine records the list of processes that are currently attached to the console. Afterwards, whenever PSReadLine runs, it will get a new list of processes attached to the console, and terminate those that are not in the original list. +When setting the **TerminateOrphanedConsoleApps** option to `$true`, PSReadLine records the list of +processes that are currently attached to the console. Afterwards, whenever PSReadLine runs, it will +get a new list of processes attached to the console, and terminate those that aren't in the original +list. This parameter and option were added in PSReadLine 2.3.2-beta2.