Skip to content

Instantly share code, notes, and snippets.

@tig
Last active April 16, 2024 16:07
Show Gist options
  • Save tig/cbbeab7f53efd73e329afd6d4b838191 to your computer and use it in GitHub Desktop.
Save tig/cbbeab7f53efd73e329afd6d4b838191 to your computer and use it in GitHub Desktop.
Use F7 as "Show Command History" in Powershell

Install F7History from the PowerShell Gallery.

Install-Module -Name "F7History"

Add a line to import F7History in your PowerShell $profile:

Import-Module -Name "F7History"

To change the key bindings, use the -ArgumentList parameter when importing the module. For example, to use F6 and Shift-F6 instead of F7 and Shift-F7:

Import-Module -Name "F7History" -ArgumentList  @{Key = "F6"; AllKey = "Shift-F6"}

Usage

At the PowerShell command line:

  • Press F7 to see the history for the current PowerShell instance.
  • Press Shift-F7 to see the history for all PowerShell instances.

Whatever was typed on the command line before hitting F7 or Shift-F7 will be used for the Out-ConsoleGridView `-Filter`` parameter.

When the Command Line History window is displayed:

  • Use the arrow keys or mouse to select an item.
  • Use ENTER to insert the selected item on the command line.
  • Use ESC to close the window without inserting anything on the command line.
# See https://github.com/gui-cs/F7Hisoty which replaces this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment