From 3fad101e32d2062d19925ba9f715336bc478763e Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Tue, 22 Aug 2023 16:34:50 -0500 Subject: [PATCH 1/2] Update docs for PromptText parameter (#10364) --- reference/5.1/PSReadLine/PSReadLine.md | 4 +- .../5.1/PSReadLine/Set-PSReadLineOption.md | 67 ++++++++++-------- .../7.2/PSReadLine/Set-PSReadLineOption.md | 69 +++++++++++-------- .../7.3/PSReadLine/Set-PSReadLineOption.md | 67 ++++++++++-------- .../7.4/PSReadLine/Set-PSReadLineOption.md | 62 ++++++++++------- 5 files changed, 159 insertions(+), 110 deletions(-) diff --git a/reference/5.1/PSReadLine/PSReadLine.md b/reference/5.1/PSReadLine/PSReadLine.md index f7f1a044c724..9b74cf7cc63d 100644 --- a/reference/5.1/PSReadLine/PSReadLine.md +++ b/reference/5.1/PSReadLine/PSReadLine.md @@ -15,8 +15,7 @@ title: PSReadLine The PSReadLine module contains cmdlets that let you customize the command-line editing environment in PowerShell. -There have been many updates to PSReadLine since the version that ships in -Windows PowerShell 5.1. +There have been many updates to PSReadLine since the version that ships in Windows PowerShell 5.1. - PowerShell 7.3.0 ships with PSReadLine 2.2.6 - PowerShell 7.2.5 ships with PSReadLine 2.1.0 @@ -47,4 +46,3 @@ Binds keys to user-defined or PSReadLine key handler functions. ### [Set-PSReadLineOption](Set-PSReadLineOption.md) Customizes the behavior of command line editing in **PSReadLine**. - diff --git a/reference/5.1/PSReadLine/Set-PSReadLineOption.md b/reference/5.1/PSReadLine/Set-PSReadLineOption.md index 8156d6309c63..32efc2756ed9 100644 --- a/reference/5.1/PSReadLine/Set-PSReadLineOption.md +++ b/reference/5.1/PSReadLine/Set-PSReadLineOption.md @@ -1,8 +1,8 @@ --- external help file: Microsoft.PowerShell.PSReadLine2.dll-Help.xml Locale: en-US -Module Name: PSReadline -ms.date: 07/19/2023 +Module Name: PSReadLine +ms.date: 08/22/2023 online version: https://learn.microsoft.com/powershell/module/psreadline/set-psreadlineoption?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: Set-PSReadLineOption @@ -199,11 +199,28 @@ Set-PSReadLineOption -CommandValidationHandler { Set-PSReadLineKeyHandler -Chord Enter -Function ValidateAndAcceptLine ``` +### Example 9: Using the PromptText parameter + +When there's a parse error, **PSReadLine** changes a part of the prompt red. The **PromptText** +parameter tells **PSReadLine** the part of the prompt string to make red. + +For example, the following example creates a prompt that contains the current path followed by the +greater-than character (`>`) and a space. + +```powershell +function prompt { "PS $pwd> " }` +Set-PSReadLineOption -PromptText '> ' # change the '>' character red +Set-PSReadLineOption -PromptText '> ', 'X ' # replace the '>' character with a red 'X' +``` + +The first string is the portion of your prompt string that you want to make red when there is a +parse error. The second string is an alternate string to use for when there is a parse error. + ## PARAMETERS ### -AddToHistoryHandler -Specifies a **ScriptBlock** that controls which commands get added to **PSReadLine** history. +Specifies a **ScriptBlock** that controls how commands get added to **PSReadLine** history. The **ScriptBlock** receives the command line as input. @@ -281,12 +298,13 @@ 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). +The argument is a hash table where the keys specify the elements and the values specify the color. +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 -escape sequence for red text is `$([char]0x1b)[91m`. In PowerShell 6 and above, the same escape +escape sequence for red text is `$([char]0x1b)[91m`. In PowerShell 6 and newer, the same escape sequence is `` `e[91m``. You can specify other escape sequences including the following types: - 256 color @@ -294,7 +312,8 @@ sequence is `` `e[91m``. You can specify other escape sequences including the fo - 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: @@ -332,8 +351,8 @@ Specifies a **ScriptBlock** that is called from **ValidateAndAcceptLine**. If an thrown, validation fails and the error is reported. Before throwing an exception, the validation handler can place the cursor at the point of the error -to make it easier to fix. A validation handler can also change the command line, such as to correct -common typographical errors. +to make it easier to fix. A validation handler can also change the command line to correct common +typographical errors. **ValidateAndAcceptLine** is used to avoid cluttering your history with commands that can't work. @@ -627,20 +646,15 @@ Accept wildcard characters: False ### -PromptText -When there's a parse error, **PSReadLine** changes a part of the prompt red. **PSReadLine** analyzes -your prompt function to determine how to change only the color of part of your prompt. This analysis -isn't 100% reliable. - -Use this option if **PSReadLine** is changing your prompt in unexpected ways. Include any trailing -whitespace. - -For example, if your prompt function looked like the following example: - -`function prompt { Write-Host -NoNewLine -ForegroundColor Yellow "$pwd"; return "# " }` +This parameter sets the value of the **PromptText** property. The default value is `"> "`. -Then set: +**PSReadLine** analyzes your prompt function to determine how to change only the color of part of +your prompt. This analysis isn't 100% reliable. Use this option if **PSReadLine** is changing your +prompt in unexpected ways. Include any trailing whitespace. -`Set-PSReadLineOption -PromptText "# "` +The value of this parameter can be a single string or an array of two strings. The first string is +the portion of your prompt string that you want to be changed to red when there is a parse error. +The second string is an alternate string to use for when there is a parse error. ```yaml Type: System.String[] @@ -661,10 +675,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: @@ -703,12 +716,12 @@ Accept wildcard characters: False ### -ViModeIndicator -This option sets the visual indication for the current **Vi** mode. Either insert mode or command +This option sets the visual indicator for the current **Vi** mode. Either insert mode or command mode. The valid values are as follows: -- **None**: There's no indication. +- **None**: There's no indicator. - **Prompt**: The prompt changes color. - **Cursor**: The cursor changes size. - **Script**: User-specified text is printed. diff --git a/reference/7.2/PSReadLine/Set-PSReadLineOption.md b/reference/7.2/PSReadLine/Set-PSReadLineOption.md index b220a01cf2cf..4b1d9d575c4d 100644 --- a/reference/7.2/PSReadLine/Set-PSReadLineOption.md +++ b/reference/7.2/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/22/2023 online version: https://learn.microsoft.com/powershell/module/psreadline/set-psreadlineoption?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 title: Set-PSReadLineOption @@ -200,11 +200,28 @@ Set-PSReadLineOption -CommandValidationHandler { Set-PSReadLineKeyHandler -Chord Enter -Function ValidateAndAcceptLine ``` +### Example 9: Using the PromptText parameter + +When there's a parse error, **PSReadLine** changes a part of the prompt red. The **PromptText** +parameter tells **PSReadLine** the part of the prompt string to make red. + +For example, the following example creates a prompt that contains the current path followed by the +greater-than character (`>`) and a space. + +```powershell +function prompt { "PS $pwd> " }` +Set-PSReadLineOption -PromptText '> ' # change the '>' character red +Set-PSReadLineOption -PromptText '> ', 'X ' # replace the '>' character with a red 'X' +``` + +The first string is the portion of your prompt string that you want to make red when there is a +parse error. The second string is an alternate string to use for when there is a parse error. + ## PARAMETERS ### -AddToHistoryHandler -Specifies a **ScriptBlock** that controls which commands get added to **PSReadLine** history. +Specifies a **ScriptBlock** that controls how commands get added to **PSReadLine** history. The **ScriptBlock** receives the command line as input. @@ -282,18 +299,19 @@ 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). +The argument is a hash table where the keys specify the elements and the values specify the color. +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 -escape sequence for red text is `$([char]0x1b)[91m`. In PowerShell 6 and above, the same escape +escape sequence for red text is `$([char]0x1b)[91m`. In PowerShell 6 and newer, the same escape sequence is `` `e[91m``. You can specify other escape sequences including the following types: Two color settings were added to support customization of the `ListView` in PSReadLine 2.2.0: - **ListPredictionColor** - set color for the leading `>` character and the trailing source name, - e.g. `[History]`. By default, it uses `DarkYellow` as the foreground color. + such as `[History]`. By default, it uses `DarkYellow` as the foreground color. - **ListPredictionSelectedColor** - set color for indicating a list item is selected. By default, it uses `DarkBlack` as the background color. @@ -302,7 +320,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: @@ -343,8 +362,8 @@ Specifies a **ScriptBlock** that is called from **ValidateAndAcceptLine**. If an thrown, validation fails and the error is reported. Before throwing an exception, the validation handler can place the cursor at the point of the error -to make it easier to fix. A validation handler can also change the command line, such as to correct -common typographical errors. +to make it easier to fix. A validation handler can also change the command line to correct common +typographical errors. **ValidateAndAcceptLine** is used to avoid cluttering your history with commands that can't work. @@ -514,7 +533,7 @@ If you don't use this parameter, the default path is as follows: **Windows** -- `$env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\$($HOST.Name)_history.txt` +- `$env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\$($Host.Name)_history.txt` **non-Windows** @@ -693,20 +712,15 @@ Accept wildcard characters: False ### -PromptText -When there's a parse error, **PSReadLine** changes a part of the prompt red. **PSReadLine** analyzes -your prompt function to determine how to change only the color of part of your prompt. This analysis -isn't 100% reliable. - -Use this option if **PSReadLine** is changing your prompt in unexpected ways. Include any trailing -whitespace. - -For example, if your prompt function looked like the following example: - -`function prompt { Write-Host -NoNewLine -ForegroundColor Yellow "$pwd"; return "# " }` +This parameter sets the value of the **PromptText** property. The default value is `"> "`. -Then set: +**PSReadLine** analyzes your prompt function to determine how to change only the color of part of +your prompt. This analysis isn't 100% reliable. Use this option if **PSReadLine** is changing your +prompt in unexpected ways. Include any trailing whitespace. -`Set-PSReadLineOption -PromptText "# "` +The value of this parameter can be a single string or an array of two strings. The first string is +the portion of your prompt string that you want to be changed to red when there is a parse error. +The second string is an alternate string to use for when there is a parse error. ```yaml Type: System.String[] @@ -727,10 +741,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: @@ -769,12 +782,12 @@ Accept wildcard characters: False ### -ViModeIndicator -This option sets the visual indication for the current **Vi** mode. Either insert mode or command +This option sets the visual indicator for the current **Vi** mode. Either insert mode or command mode. The valid values are as follows: -- **None**: There's no indication. +- **None**: There's no indicator. - **Prompt**: The prompt changes color. - **Cursor**: The cursor changes size. - **Script**: User-specified text is printed. diff --git a/reference/7.3/PSReadLine/Set-PSReadLineOption.md b/reference/7.3/PSReadLine/Set-PSReadLineOption.md index 335a175cd456..3d44b2dac3f7 100644 --- a/reference/7.3/PSReadLine/Set-PSReadLineOption.md +++ b/reference/7.3/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/22/2023 online version: https://learn.microsoft.com/powershell/module/psreadline/set-psreadlineoption?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 title: Set-PSReadLineOption @@ -200,11 +200,28 @@ Set-PSReadLineOption -CommandValidationHandler { Set-PSReadLineKeyHandler -Chord Enter -Function ValidateAndAcceptLine ``` +### Example 9: Using the PromptText parameter + +When there's a parse error, **PSReadLine** changes a part of the prompt red. The **PromptText** +parameter tells **PSReadLine** the part of the prompt string to make red. + +For example, the following example creates a prompt that contains the current path followed by the +greater-than character (`>`) and a space. + +```powershell +function prompt { "PS $pwd> " }` +Set-PSReadLineOption -PromptText '> ' # change the '>' character red +Set-PSReadLineOption -PromptText '> ', 'X ' # replace the '>' character with a red 'X' +``` + +The first string is the portion of your prompt string that you want to make red when there is a +parse error. The second string is an alternate string to use for when there is a parse error. + ## PARAMETERS ### -AddToHistoryHandler -Specifies a **ScriptBlock** that controls which commands get added to **PSReadLine** history. +Specifies a **ScriptBlock** that controls how commands get added to **PSReadLine** history. The **ScriptBlock** receives the command line as input. @@ -282,18 +299,19 @@ 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). +The argument is a hash table where the keys specify the elements and the values specify the color. +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 -escape sequence for red text is `$([char]0x1b)[91m`. In PowerShell 6 and above, the same escape +escape sequence for red text is `$([char]0x1b)[91m`. In PowerShell 6 and newer, the same escape sequence is `` `e[91m``. You can specify other escape sequences including the following types: Two color settings were added to support customization of the `ListView` in PSReadLine 2.2.0: - **ListPredictionColor** - set color for the leading `>` character and the trailing source name, - e.g. `[History]`. By default, it uses `DarkYellow` as the foreground color. + such as `[History]`. By default, it uses `DarkYellow` as the foreground color. - **ListPredictionSelectedColor** - set color for indicating a list item is selected. By default, it uses `DarkBlack` as the background color. @@ -302,7 +320,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: @@ -343,8 +362,8 @@ Specifies a **ScriptBlock** that is called from **ValidateAndAcceptLine**. If an thrown, validation fails and the error is reported. Before throwing an exception, the validation handler can place the cursor at the point of the error -to make it easier to fix. A validation handler can also change the command line, such as to correct -common typographical errors. +to make it easier to fix. A validation handler can also change the command line to correct common +typographical errors. **ValidateAndAcceptLine** is used to avoid cluttering your history with commands that can't work. @@ -693,20 +712,15 @@ Accept wildcard characters: False ### -PromptText -When there's a parse error, **PSReadLine** changes a part of the prompt red. **PSReadLine** analyzes -your prompt function to determine how to change only the color of part of your prompt. This analysis -isn't 100% reliable. - -Use this option if **PSReadLine** is changing your prompt in unexpected ways. Include any trailing -whitespace. - -For example, if your prompt function looked like the following example: - -`function prompt { Write-Host -NoNewLine -ForegroundColor Yellow "$pwd"; return "# " }` +This parameter sets the value of the **PromptText** property. The default value is `"> "`. -Then set: +**PSReadLine** analyzes your prompt function to determine how to change only the color of part of +your prompt. This analysis isn't 100% reliable. Use this option if **PSReadLine** is changing your +prompt in unexpected ways. Include any trailing whitespace. -`Set-PSReadLineOption -PromptText "# "` +The value of this parameter can be a single string or an array of two strings. The first string is +the portion of your prompt string that you want to be changed to red when there is a parse error. +The second string is an alternate string to use for when there is a parse error. ```yaml Type: System.String[] @@ -727,10 +741,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: @@ -769,12 +782,12 @@ Accept wildcard characters: False ### -ViModeIndicator -This option sets the visual indication for the current **Vi** mode. Either insert mode or command +This option sets the visual indicator for the current **Vi** mode. Either insert mode or command mode. The valid values are as follows: -- **None**: There's no indication. +- **None**: There's no indicator. - **Prompt**: The prompt changes color. - **Cursor**: The cursor changes size. - **Script**: User-specified text is printed. diff --git a/reference/7.4/PSReadLine/Set-PSReadLineOption.md b/reference/7.4/PSReadLine/Set-PSReadLineOption.md index 7487ae5f25fb..15e90a9f88d8 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: 08/20/2023 +ms.date: 08/22/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 @@ -201,16 +201,33 @@ Set-PSReadLineOption -CommandValidationHandler { Set-PSReadLineKeyHandler -Chord Enter -Function ValidateAndAcceptLine ``` +### Example 9: Using the PromptText parameter + +When there's a parse error, **PSReadLine** changes a part of the prompt red. The **PromptText** +parameter tells **PSReadLine** the part of the prompt string to make red. + +For example, the following example creates a prompt that contains the current path followed by the +greater-than character (`>`) and a space. + +```powershell +function prompt { "PS $pwd> " }` +Set-PSReadLineOption -PromptText '> ' # change the '>' character red +Set-PSReadLineOption -PromptText '> ', 'X ' # replace the '>' character with a red 'X' +``` + +The first string is the portion of your prompt string that you want to make red when there is a +parse error. The second string is an alternate string to use for when there is a parse error. + ## PARAMETERS ### -AddToHistoryHandler -Specifies a **ScriptBlock** that controls which commands get added to **PSReadLine** history. +Specifies a **ScriptBlock** that controls how commands get added to **PSReadLine** history. 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 +254,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. @@ -283,19 +300,19 @@ 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. +The argument is a hash table where the keys specify the elements and the values specify the color. 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 -escape sequence for red text is `$([char]0x1b)[91m`. In PowerShell 6 and above, the same escape +escape sequence for red text is `$([char]0x1b)[91m`. In PowerShell 6 and newer, the same escape sequence is `` `e[91m``. You can specify other escape sequences including the following types: Two color settings were added to support customization of the `ListView` in PSReadLine 2.2.0: - **ListPredictionColor** - set color for the leading `>` character and the trailing source name, - e.g. `[History]`. By default, it uses `DarkYellow` as the foreground color. + such as `[History]`. By default, it uses `DarkYellow` as the foreground color. - **ListPredictionSelectedColor** - set color for indicating a list item is selected. By default, it uses `DarkBlack` as the background color. @@ -346,8 +363,8 @@ Specifies a **ScriptBlock** that is called from **ValidateAndAcceptLine**. If an thrown, validation fails and the error is reported. Before throwing an exception, the validation handler can place the cursor at the point of the error -to make it easier to fix. A validation handler can also change the command line, such as to correct -common typographical errors. +to make it easier to fix. A validation handler can also change the command line to correct common +typographical errors. **ValidateAndAcceptLine** is used to avoid cluttering your history with commands that can't work. @@ -696,20 +713,15 @@ Accept wildcard characters: False ### -PromptText -When there's a parse error, **PSReadLine** changes a part of the prompt red. **PSReadLine** analyzes -your prompt function to determine how to change only the color of part of your prompt. This analysis -isn't 100% reliable. - -Use this option if **PSReadLine** is changing your prompt in unexpected ways. Include any trailing -whitespace. - -For example, if your prompt function looked like the following example: - -`function prompt { Write-Host -NoNewLine -ForegroundColor Yellow "$pwd"; return "# " }` +This parameter sets the value of the **PromptText** property. The default value is `"> "`. -Then set: +**PSReadLine** analyzes your prompt function to determine how to change only the color of part of +your prompt. This analysis isn't 100% reliable. Use this option if **PSReadLine** is changing your +prompt in unexpected ways. Include any trailing whitespace. -`Set-PSReadLineOption -PromptText "# "` +The value of this parameter can be a single string or an array of two strings. The first string is +the portion of your prompt string that you want to be changed to red when there is a parse error. +The second string is an alternate string to use for when there is a parse error. ```yaml Type: System.String[] @@ -799,12 +811,12 @@ Accept wildcard characters: False ### -ViModeIndicator -This option sets the visual indication for the current **Vi** mode. Either insert mode or command +This option sets the visual indicator for the current **Vi** mode. Either insert mode or command mode. The valid values are as follows: -- **None**: There's no indication. +- **None**: There's no indicator. - **Prompt**: The prompt changes color. - **Cursor**: The cursor changes size. - **Script**: User-specified text is printed. From 78eaca777bc413876da60c48884a3a110a29e1ae Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Tue, 22 Aug 2023 16:36:52 -0500 Subject: [PATCH 2/2] Update release notes for 7.4-p5 (#10363) --- .../whats-new/What-s-New-in-PowerShell-74.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-74.md b/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-74.md index 5f1e51c16182..a3d608b1fc9e 100644 --- a/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-74.md +++ b/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-74.md @@ -1,13 +1,13 @@ --- title: What's New in PowerShell 7.4 (preview) description: New features and changes released in PowerShell 7.4 (preview) -ms.date: 06/30/2023 +ms.date: 08/22/2023 --- # What's New in PowerShell 7.4 (preview) -PowerShell 7.4-preview.4 includes the following features, updates, and breaking changes. PowerShell -7.4 is now built on .NET 8.0.0-preview.4. +PowerShell 7.4-preview.5 includes the following features, updates, and breaking changes. PowerShell +7.4 is now built on .NET 8.0.0-preview.7. For a complete list of changes, see the [CHANGELOG][15] in the GitHub repository. @@ -70,6 +70,8 @@ Many thanks to **@MartinGC94** and others for all the work on improving tab comp - Infer external application output as strings ([#19193][19193]) - Update parameter completion for enums to exclude values not allowed by `ValidateRange` attributes ([#17750][17750]) (Thanks @fflaten!). +- Fix dynamic parameter completion ([#19510][19510]) +- Add completion for variables assigned by the Data statement ([#19831][19831]) ## Web cmdlet improvements @@ -111,6 +113,7 @@ Many thanks to **@CarloToso** and others for all the work on improving web cmdle cmdlets ([#19558][19558]) (Thanks @stevenebutler!) Other cmdlets - Support Ctrl+c when connection hangs while reading data in WebCmdlets ([#19330][19330]) (Thanks @stevenebutler!) +- Support Unix domain socket in WebCmdlets ([#19343][19343]) ## Other cmdlet improvements @@ -139,6 +142,10 @@ Many thanks to **@CarloToso** and others for all the work on improving web cmdle - Add `Get-SecureRandom` cmdlet ([#19587][19587]) - `Set-Clipboard -AsOSC52` for remote usage ([#18222][18222]) (Thanks @dkaszews!) - Speed up `Resolve-Path` relative path resolution ([#19171][19171]) (Thanks @MartinGC94!) +- Added the switch parameter `-CaseInsensitive` to `Select-Object` and `Get-Unique` cmdlets + ([#19683][19683]) (Thanks @ArmaanMcleod!) +- `Restart-Computer` and `Stop-Computer` should fail with error when not running via sudo on Unix + ([#19824][19824]) ## Engine improvements @@ -282,6 +289,7 @@ For more information about the Experimental Features, see [Using Experimental Fe [19298]: https://github.com/PowerShell/PowerShell/pull/19298 [19320]: https://github.com/PowerShell/PowerShell/pull/19320 [19330]: https://github.com/PowerShell/PowerShell/pull/19330 +[19343]: https://github.com/PowerShell/PowerShell/pull/19343 [19382]: https://github.com/PowerShell/PowerShell/pull/19382 [19422]: https://github.com/PowerShell/PowerShell/pull/19422 [19442]: https://github.com/PowerShell/PowerShell/pull/19442 @@ -289,6 +297,7 @@ For more information about the Experimental Features, see [Using Experimental Fe [19489]: https://github.com/PowerShell/PowerShell/pull/19489 [19490]: https://github.com/PowerShell/PowerShell/pull/19490 [19501]: https://github.com/PowerShell/PowerShell/pull/19501 +[19510]: https://github.com/PowerShell/PowerShell/pull/19510 [19558]: https://github.com/PowerShell/PowerShell/pull/19558 [19560]: https://github.com/PowerShell/PowerShell/pull/19560 [19587]: https://github.com/PowerShell/PowerShell/pull/19587 @@ -301,3 +310,6 @@ For more information about the Experimental Features, see [Using Experimental Fe [19765]: https://github.com/PowerShell/PowerShell/pull/19765 [19814]: https://github.com/PowerShell/PowerShell/pull/19814 [19819]: https://github.com/PowerShell/PowerShell/pull/19819 +[19831]: https://github.com/PowerShell/PowerShell/pull/19831 +[19683]: https://github.com/PowerShell/PowerShell/pull/19683 +[19824]: https://github.com/PowerShell/PowerShell/pull/19824