{"id":86404,"date":"2018-08-07T00:13:05","date_gmt":"2018-08-07T08:13:05","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/koryt\/?p=625"},"modified":"2019-10-09T05:27:34","modified_gmt":"2019-10-09T13:27:34","slug":"powershell-powertip-history-of-commands-with-psreadline","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powershell-powertip-history-of-commands-with-psreadline\/","title":{"rendered":"PowerShell PowerTip: History of commands with PSReadline"},"content":{"rendered":"<p>One of the really cool things <a href=\"https:\/\/www.powershellgallery.com\/packages\/PSReadline\/1.2\">PSReadline <\/a>provides (module shipping on v5+) isn&#8217;t as immediately obvious as the syntax highlighting. It offers a persistent history that is stored from session to session.<\/p>\n<p>This means if you run commands in a window, close it, and open a new one later you can still hit the up arrow and scroll through them. I use this feature quite a bit doing demos or just working on things where I want to clear out my whole scope and jump back in.<\/p>\n<p>If you want to opt out you can as well:<\/p>\n<pre class=\"lang:ps decode:true \">&lt;span&gt;Set-PSReadLineOption -&lt;\/span&gt;&lt;span class=\"highlight\" id=\"0.6822782376879328\" name=\"searchHitInReadingPane\"&gt;History&lt;\/span&gt;&lt;span&gt;SaveStyle\u00a0&lt;\/span&gt;&lt;span&gt;SaveAtExit #will only save the history once you close the window&lt;\/span&gt;\r\n\r\n&lt;span&gt;Set-PSReadLineOption -&lt;\/span&gt;&lt;span class=\"highlight\" id=\"0.6822782376879328\" name=\"searchHitInReadingPane\"&gt;History&lt;\/span&gt;&lt;span&gt;SaveStyle\u00a0SaveNothing #turns this off&lt;\/span&gt;<\/pre>\n<p>Hope that helps, tune in more often to get short and sweet PowerTips!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the really cool things PSReadline provides (module shipping on v5+) isn&#8217;t as immediately obvious as the syntax highlighting. It offers a persistent history that is stored from session to session. This means if you run commands in a window, close it, and open a new one later you can still hit the up [&hellip;]<\/p>\n","protected":false},"author":7300,"featured_media":87096,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1738],"tags":[2221,2125,377,356],"class_list":["post-86404","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-kory-thacher","tag-koryt","tag-powershell","tag-powertip"],"acf":[],"blog_post_summary":"<p>One of the really cool things PSReadline provides (module shipping on v5+) isn&#8217;t as immediately obvious as the syntax highlighting. It offers a persistent history that is stored from session to session. This means if you run commands in a window, close it, and open a new one later you can still hit the up [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/86404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/7300"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=86404"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/86404\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=86404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=86404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=86404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}