Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7/11/2023 PM Publish #10270

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion reference/5.1/PSReadLine/Set-PSReadLineOption.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.PSReadLine2.dll-Help.xml
Locale: en-US
Module Name: PSReadline
ms.date: 03/24/2023
ms.date: 07/11/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
Expand Down Expand Up @@ -32,6 +32,11 @@ Set-PSReadLineOption [-EditMode <EditMode>] [-ContinuationPrompt <String>] [-His
The `Set-PSReadLineOption` cmdlet customizes the behavior of the **PSReadLine** module when you're
editing the command line. To view the **PSReadLine** settings, use `Get-PSReadLineOption`.

The options set by this command only apply to the current session. To persist any options, add them
to a profile script. For more information, see
[about_Profiles](../Microsoft.PowerShell.Core/About/about_Profiles.md) and
[Customizing your shell environment](/powershell/scripting/learn/shell/creating-profiles).

## EXAMPLES

### Example 1: Set foreground and background colors
Expand Down Expand Up @@ -141,6 +146,29 @@ block object.
For more information, see
[about_Providers](/powershell/module/microsoft.powershell.core/about/about_providers).

### Example 7: Use HistoryHandler to filter commands added to history

The following example shows how to use the `AddToHistoryHandler` to prevent saving any git commands
to history.

```powershell
$ScriptBlock = {
Param([string]$line)

if ($line -match "^git") {
return $false
} else {
return $true
}
}

Set-PSReadLineOption -AddToHistoryHandler $ScriptBlock
```

The scriptblock returns `$false` if the command started with `git`. This has the same effect as
returning the `SkipAdding` **AddToHistory** enum. If the command doesn't start with `git`, the
handler returns `$true` and PSReadLine saves the command in history.

## PARAMETERS

### -AddToHistoryHandler
Expand Down
30 changes: 29 additions & 1 deletion reference/7.2/PSReadLine/Set-PSReadLineOption.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.PSReadLine2.dll-Help.xml
Locale: en-US
Module Name: PSReadLine
ms.date: 03/24/2023
ms.date: 07/11/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
Expand Down Expand Up @@ -33,6 +33,11 @@ Set-PSReadLineOption [-EditMode <EditMode>] [-ContinuationPrompt <String>] [-His
The `Set-PSReadLineOption` cmdlet customizes the behavior of the **PSReadLine** module when you're
editing the command line. To view the **PSReadLine** settings, use `Get-PSReadLineOption`.

The options set by this command only apply to the current session. To persist any options, add them
to a profile script. For more information, see
[about_Profiles](../Microsoft.PowerShell.Core/About/about_Profiles.md) and
[Customizing your shell environment](/powershell/scripting/learn/shell/creating-profiles).

## EXAMPLES

### Example 1: Set foreground and background colors
Expand Down Expand Up @@ -142,6 +147,29 @@ block object.
For more information, see
[about_Providers](/powershell/module/microsoft.powershell.core/about/about_providers).

### Example 7: Use HistoryHandler to filter commands added to history

The following example shows how to use the `AddToHistoryHandler` to prevent saving any git commands
to history.

```powershell
$ScriptBlock = {
Param([string]$line)

if ($line -match "^git") {
return $false
} else {
return $true
}
}

Set-PSReadLineOption -AddToHistoryHandler $ScriptBlock
```

The scriptblock returns `$false` if the command started with `git`. This has the same effect as
returning the `SkipAdding` **AddToHistory** enum. If the command doesn't start with `git`, the
handler returns `$true` and PSReadLine saves the command in history.

## PARAMETERS

### -AddToHistoryHandler
Expand Down
30 changes: 29 additions & 1 deletion reference/7.3/PSReadLine/Set-PSReadLineOption.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.PSReadLine2.dll-Help.xml
Locale: en-US
Module Name: PSReadLine
ms.date: 03/24/2023
ms.date: 07/11/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
Expand Down Expand Up @@ -33,6 +33,11 @@ Set-PSReadLineOption [-EditMode <EditMode>] [-ContinuationPrompt <String>] [-His
The `Set-PSReadLineOption` cmdlet customizes the behavior of the **PSReadLine** module when you're
editing the command line. To view the **PSReadLine** settings, use `Get-PSReadLineOption`.

The options set by this command only apply to the current session. To persist any options, add them
to a profile script. For more information, see
[about_Profiles](../Microsoft.PowerShell.Core/About/about_Profiles.md) and
[Customizing your shell environment](/powershell/scripting/learn/shell/creating-profiles).

## EXAMPLES

### Example 1: Set foreground and background colors
Expand Down Expand Up @@ -142,6 +147,29 @@ block object.
For more information, see
[about_Providers](/powershell/module/microsoft.powershell.core/about/about_providers).

### Example 7: Use HistoryHandler to filter commands added to history

The following example shows how to use the `AddToHistoryHandler` to prevent saving any git commands
to history.

```powershell
$ScriptBlock = {
Param([string]$line)

if ($line -match "^git") {
return $false
} else {
return $true
}
}

Set-PSReadLineOption -AddToHistoryHandler $ScriptBlock
```

The scriptblock returns `$false` if the command started with `git`. This has the same effect as
returning the `SkipAdding` **AddToHistory** enum. If the command doesn't start with `git`, the
handler returns `$true` and PSReadLine saves the command in history.

## PARAMETERS

### -AddToHistoryHandler
Expand Down
30 changes: 29 additions & 1 deletion reference/7.4/PSReadLine/Set-PSReadLineOption.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.PSReadLine2.dll-Help.xml
Locale: en-US
Module Name: PSReadLine
ms.date: 03/24/2023
ms.date: 07/11/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
Expand Down Expand Up @@ -33,6 +33,11 @@ Set-PSReadLineOption [-EditMode <EditMode>] [-ContinuationPrompt <String>] [-His
The `Set-PSReadLineOption` cmdlet customizes the behavior of the **PSReadLine** module when you're
editing the command line. To view the **PSReadLine** settings, use `Get-PSReadLineOption`.

The options set by this command only apply to the current session. To persist any options, add them
to a profile script. For more information, see
[about_Profiles](../Microsoft.PowerShell.Core/About/about_Profiles.md) and
[Customizing your shell environment](/powershell/scripting/learn/shell/creating-profiles).

## EXAMPLES

### Example 1: Set foreground and background colors
Expand Down Expand Up @@ -142,6 +147,29 @@ block object.
For more information, see
[about_Providers](/powershell/module/microsoft.powershell.core/about/about_providers).

### Example 7: Use HistoryHandler to filter commands added to history

The following example shows how to use the `AddToHistoryHandler` to prevent saving any git commands
to history.

```powershell
$ScriptBlock = {
Param([string]$line)

if ($line -match "^git") {
return $false
} else {
return $true
}
}

Set-PSReadLineOption -AddToHistoryHandler $ScriptBlock
```

The scriptblock returns `$false` if the command started with `git`. This has the same effect as
returning the `SkipAdding` **AddToHistory** enum. If the command doesn't start with `git`, the
handler returns `$true` and PSReadLine saves the command in history.

## PARAMETERS

### -AddToHistoryHandler
Expand Down