Skip to content

Commit f8df952

Browse files
Fixes #10346 - Document new TerminateOrphanedConsoleApps switch (#10355)
* Document new TerminateOrphanedConsoleApps switch * Apply suggestions from code review Co-authored-by: Dongbo Wang <dongbow@microsoft.com> * Feedback changes --------- Co-authored-by: Dongbo Wang <dongbow@microsoft.com>
1 parent 28059c3 commit f8df952

File tree

2 files changed

+58
-20
lines changed

2 files changed

+58
-20
lines changed

reference/7.4/PSReadLine/Get-PSReadLineOption.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.PSReadLine2.dll-Help.xml
33
Locale: en-US
44
Module Name: PSReadLine
5-
ms.date: 12/13/2022
5+
ms.date: 08/20/2023
66
online version: https://learn.microsoft.com/powershell/module/psreadline/get-psreadlineoption?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Get-PSReadLineOption
@@ -46,33 +46,41 @@ HistorySearchCursorMovesToEnd : False
4646
MaximumHistoryCount : 4096
4747
ContinuationPrompt : >>
4848
ExtraPromptLineCount : 0
49-
PromptText : {> }
49+
PromptText : >
5050
BellStyle : Audible
5151
DingDuration : 50
5252
DingTone : 1221
53-
CommandsToValidateScriptBlockArguments : {ForEach-Object, %, Invoke-Command, icm...}
53+
CommandsToValidateScriptBlockArguments : {ForEach-Object, %, Invoke-Command, icm}
5454
CommandValidationHandler :
5555
CompletionQueryItems : 100
5656
MaximumKillRingCount : 10
5757
ShowToolTips : True
5858
ViModeIndicator : None
59-
WordDelimiters : ;:,.[]{}()/\|^&*-=+'"---
59+
WordDelimiters : ;:,.[]{}()/\|!?^&*-=+'"–—―
6060
AnsiEscapeTimeout : 100
61+
PredictionSource : HistoryAndPlugin
62+
PredictionViewStyle : InlineView
63+
TerminateOrphanedConsoleApps : False
6164
CommandColor : "`e[93m"
6265
CommentColor : "`e[32m"
63-
ContinuationPromptColor : "`e[97m"
64-
DefaultTokenColor : "`e[97m"
66+
ContinuationPromptColor : "`e[37m"
67+
DefaultTokenColor : "`e[37m"
6568
EmphasisColor : "`e[96m"
6669
ErrorColor : "`e[91m"
70+
InlinePredictionColor : "`e[97;2;3m"
6771
KeywordColor : "`e[92m"
68-
MemberColor : "`e[97m"
72+
ListPredictionColor : "`e[33m"
73+
ListPredictionSelectedColor : "`e[48;5;238m"
74+
ListPredictionTooltipColor : "`e[97;2;3m"
75+
MemberColor : "`e[37m"
6976
NumberColor : "`e[97m"
7077
OperatorColor : "`e[90m"
7178
ParameterColor : "`e[90m"
72-
SelectionColor : "`e[30;107m"
79+
SelectionColor : "`e[30;47m"
7380
StringColor : "`e[36m"
7481
TypeColor : "`e[37m"
7582
VariableColor : "`e[92m"
83+
7684
```
7785

7886
This command returns the list of available PSReadLine options and their current values.

reference/7.4/PSReadLine/Set-PSReadLineOption.md

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.PSReadLine2.dll-Help.xml
33
Locale: en-US
44
Module Name: PSReadLine
5-
ms.date: 07/19/2023
5+
ms.date: 08/20/2023
66
online version: https://learn.microsoft.com/powershell/module/psreadline/set-psreadlineoption?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Set-PSReadLineOption
@@ -25,7 +25,8 @@ Set-PSReadLineOption [-EditMode <EditMode>] [-ContinuationPrompt <String>] [-His
2525
[-HistorySearchCaseSensitive] [-HistorySaveStyle <HistorySaveStyle>] [-HistorySavePath <String>]
2626
[-AnsiEscapeTimeout <Int32>] [-PromptText <String[]>] [-ViModeIndicator <ViModeStyle>]
2727
[-ViModeChangeHandler <ScriptBlock>] [-PredictionSource <PredictionSource>]
28-
[-PredictionViewStyle <PredictionViewStyle>] [-Colors <Hashtable>] [<CommonParameters>]
28+
[-PredictionViewStyle <PredictionViewStyle>] [-Colors <Hashtable>] [-TerminateOrphanedConsoleApps]
29+
[<CommonParameters>]
2930
```
3031

3132
## DESCRIPTION
@@ -208,8 +209,8 @@ Specifies a **ScriptBlock** that controls which commands get added to **PSReadLi
208209

209210
The **ScriptBlock** receives the command line as input.
210211

211-
The **ScripBlock** should return a member of the **AddToHistoryOption** enum, the string name of
212-
one of those members, or a boolean value. The list below describes the possible values and their
212+
The **ScripBlock** should return a member of the **AddToHistoryOption** enum, the string name of one
213+
of those members, or a boolean value. The list below describes the possible values and their
213214
effects.
214215

215216
- `MemoryAndFile` - Add the command to the history file and the current session.
@@ -236,8 +237,8 @@ This option is specific to Windows when input is redirected, for example, when r
236237
or `screen`.
237238

238239
With redirected input on Windows, many keys are sent as a sequence of characters starting with the
239-
escape character. It's impossible to distinguish between a single escape character followed by
240-
more characters and a valid escape sequence.
240+
escape character. It's impossible to distinguish between a single escape character followed by more
241+
characters and a valid escape sequence.
241242

242243
The assumption is that the terminal can send the characters faster than a user types. **PSReadLine**
243244
waits for this timeout before concluding that it has received a complete escape sequence.
@@ -283,7 +284,8 @@ Accept wildcard characters: False
283284
The **Colors** parameter specifies various colors used by **PSReadLine**.
284285

285286
The argument is a hash table where the keys specify which element and the values specify the color.
286-
For more information, see [about_Hash_Tables](/powershell/module/microsoft.powershell.core/about/about_hash_tables).
287+
For more information, see
288+
[about_Hash_Tables](/powershell/module/microsoft.powershell.core/about/about_hash_tables).
287289

288290
Colors can be either a value from **ConsoleColor**, for example `[ConsoleColor]::Red`, or a valid
289291
ANSI escape sequence. Valid escape sequences depend on your terminal. In PowerShell 5.0, an example
@@ -302,7 +304,8 @@ Two color settings were added to support customization of the `ListView` in PSRe
302304
- Foreground, background, or both
303305
- Inverse, bold
304306

305-
For more information about ANSI color codes, see [ANSI escape code](https://wikipedia.org/wiki/ANSI_escape_code#Colors_) in Wikipedia.
307+
For more information about ANSI color codes, see the Wikipedia article
308+
[ANSI escape code](https://wikipedia.org/wiki/ANSI_escape_code#Colors_).
306309

307310
The valid keys include:
308311

@@ -727,10 +730,9 @@ When displaying possible completions, tooltips are shown in the list of completi
727730
This option is enabled by default. This option wasn't enabled by default in prior versions of
728731
**PSReadLine**. To disable, set this option to `$False`.
729732

730-
By default, the **ShowToolTips** property of the global **PSConsoleReadLineOptions**
731-
object is set to `True`. Using this **SwitchParameter** sets the property value to `True`. To change
732-
the property value, you must specify the value of the **SwitchParameter** as follows:
733-
`-ShowToolTips:$False`.
733+
By default, the **ShowToolTips** property of the global **PSConsoleReadLineOptions** object is set
734+
to `True`. Using this **SwitchParameter** sets the property value to `True`. To change the property
735+
value, you must specify the value of the **SwitchParameter** as follows: `-ShowToolTips:$False`.
734736

735737
Using the following command, you can set the property value directly:
736738

@@ -748,6 +750,34 @@ Accept pipeline input: False
748750
Accept wildcard characters: False
749751
```
750752

753+
### -TerminateOrphanedConsoleApps
754+
755+
This parameter sets the **TerminateOrphanedConsoleApps** option to `$true`.
756+
757+
On Windows, when you press <kbd>Ctrl</kbd>+<kbd>c</kbd> to terminate a process, each process
758+
attached to a console receives a terminate signal, as opposed to just the active shell. Sometimes,
759+
when a shell has launched some large tree of child processes, (imagine a build system, for example)
760+
some processes may exit, leaving multiple processes concurrently trying to consume console input.
761+
762+
When setting the **TerminateOrphanedConsoleApps** option to `$true`, PSReadLine records the list of
763+
processes that are currently attached to the console. Afterwards, whenever PSReadLine runs, it will
764+
get a new list of processes attached to the console, and terminate those that aren't in the original
765+
list.
766+
767+
This parameter and option were added in PSReadLine 2.3.2-beta2.
768+
769+
```yaml
770+
Type: System.Management.Automation.SwitchParameter
771+
Parameter Sets: (All)
772+
Aliases:
773+
774+
Required: False
775+
Position: Named
776+
Default value: None
777+
Accept pipeline input: False
778+
Accept wildcard characters: False
779+
```
780+
751781
### -ViModeChangeHandler
752782

753783
When the **ViModeIndicator** is set to `Script`, the script block provided will be invoked every

0 commit comments

Comments
 (0)