locked
command history window for ISE? (F7) RRS feed

  • Question

  • F7 doesn't seem to work in ISE. I realize the up and down etc works, but is there no way to pop up a window with a list?

    Tuesday, September 14, 2010 7:25 PM

Answers

  • Well, I played a bit with that and came up with code below (requires WPK):
    function Copy-HistoryItem {
      New-Window -Width 800 -Height 100 {
        New-ListBox -On_PreviewMouseDoubleClick {
          $psISE.CurrentPowerShellTab.CommandPane.InsertText($this.SelectedValue)
          $this.parent.close()
        } -Items $(Get-History | select -ExpandProperty CommandLine)
      } -Show
    }<br/>
    $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('Show history',{Copy-HistoryItem},"F7")
    

    Of course it can be done in similar way with other GUI solutions, but I simply know WPK best, that's why I used it. ;)

    It will add F7 shorcut. :)

    • Marked as answer by jrich Wednesday, September 15, 2010 6:29 PM
    Tuesday, September 14, 2010 9:30 PM
  •        Thanks for the example! I took that and made it run in pure PS (no WPK required) and added some features.

    http://jrich523.wordpress.com/2010/09/15/powershell-ise-history-window-why-no-f7-for-ise/

    Thanks!

    • Marked as answer by jrich Wednesday, September 15, 2010 6:29 PM
    Wednesday, September 15, 2010 6:27 PM

All replies

  • Well, I played a bit with that and came up with code below (requires WPK):
    function Copy-HistoryItem {
      New-Window -Width 800 -Height 100 {
        New-ListBox -On_PreviewMouseDoubleClick {
          $psISE.CurrentPowerShellTab.CommandPane.InsertText($this.SelectedValue)
          $this.parent.close()
        } -Items $(Get-History | select -ExpandProperty CommandLine)
      } -Show
    }<br/>
    $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('Show history',{Copy-HistoryItem},"F7")
    

    Of course it can be done in similar way with other GUI solutions, but I simply know WPK best, that's why I used it. ;)

    It will add F7 shorcut. :)

    • Marked as answer by jrich Wednesday, September 15, 2010 6:29 PM
    Tuesday, September 14, 2010 9:30 PM
  •        Thanks for the example! I took that and made it run in pure PS (no WPK required) and added some features.

    http://jrich523.wordpress.com/2010/09/15/powershell-ise-history-window-why-no-f7-for-ise/

    Thanks!

    • Marked as answer by jrich Wednesday, September 15, 2010 6:29 PM
    Wednesday, September 15, 2010 6:27 PM
  • Here's another way using Out-Gridview. Using this method you can even select multiple lines from your history and run them again.

    Get-History | select -ExpandProperty commandline | ogv -OutputMode Multiple | Invoke-Expression
    • Proposed as answer by JonWalz Wednesday, February 17, 2016 2:38 PM
    Wednesday, February 17, 2016 2:38 PM