{"id":8969,"date":"2022-03-28T11:14:59","date_gmt":"2022-03-28T15:14:59","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=8969"},"modified":"2022-03-28T15:26:41","modified_gmt":"2022-03-28T19:26:41","slug":"powershell-predicting-with-style","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/","title":{"rendered":"PowerShell Predicting with Style"},"content":{"rendered":"\n<p>I've been using the PSReadline module for years in PowerShell. I especially loved it when the module added inline command prediction based on your history. You would start typing a command and the module would search your saved history and suggest an inline completion.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/inline-prediction.png\"><img loading=\"lazy\" decoding=\"async\" width=\"581\" height=\"155\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/inline-prediction.png\" alt=\"PSReadline Inline prediction\" class=\"wp-image-8970\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/inline-prediction.png 581w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/inline-prediction-300x80.png 300w\" sizes=\"auto, (max-width: 581px) 100vw, 581px\" \/><\/a><\/figure>\n\n\n\n<p>In my PowerShell profile I enable and configure this feature.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Set-PSReadLineOption -PredictionSource History -colors @{\n    InlinePrediction = \"$([char]27)[4;92m\"\n}<\/code><\/pre>\n\n\n\n<p>Recently, Microsoft updated the PSReadline module to version 2.2.2. You can install it from the PowerShell  Gallery. If you've never updated the module, you will need to actually install it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Install-Module PSReadline -force<\/code><\/pre>\n\n\n\n<p>This is because PSReadline ships with PowerShell. Once you've installed a newer version, you can use Update-Module to keep it up to date.<\/p>\n\n\n\n<p>The newer version brings an alternate prediction view style. You can now specify a list view.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Set-PSReadLineOption -PredictionViewStyle ListView<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/list-prediction.png\"><img loading=\"lazy\" decoding=\"async\" width=\"932\" height=\"259\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/list-prediction.png\" alt=\"PSReadline List prediction view\" class=\"wp-image-8971\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/list-prediction.png 932w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/list-prediction-300x83.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/list-prediction-768x213.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/list-prediction-850x236.png 850w\" sizes=\"auto, (max-width: 932px) 100vw, 932px\" \/><\/a><\/figure>\n\n\n\n<p>Arrow down to the selection you want, and press Enter. It may not seem like much, but it is little things like this that save time throughout your day and remove a bit of command-line friction.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Toggle Style<\/h2>\n\n\n\n<p>What I have found is that sometimes I want inline prediction and sometimes I want a list. But I don't want to be constantly running<a href=\"https:\/\/docs.microsoft.com\/powershell\/module\/psreadline\/set-psreadlineoption?view=powershell-7.1&amp;W     T.mc_id=ps-gethelp\" target=\"_blank\" rel=\"noreferrer noopener\"> Set-PSReadlineOption<\/a>. Although with command prediction, I guess it wouldn't be too bad. Instead, I wrote a PowerShell function that by default toggles the prediction view style.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Set-PredictionView {\n    [cmdletbinding(SupportsShouldProcess)]\n    [alias(\"spv\", 'sview')]\n    [OutputType(\"none\")]\n    Param(\n        [Parameter(Position = 0, HelpMessage = \"Specify the prediction style. Toggle will switch to the unused style.\")]\n        [ValidateSet(\"List\", \"InLine\", \"Toggle\")]\n        [string]$View = \"Toggle\",\n        [switch]$Passthru\n    )\n\n    Try {\n        Switch ($View) {\n            \"List\" { $style = \"ListView\" }\n            \"Inline\" { $style = \"InLineView\" }\n            \"Toggle\" {\n                Switch ((Get-PSReadLineOption).PredictionViewStyle) {\n                    \"InLineview\" {\n                        $style = \"ListView\"\n                    }\n                    \"ListView\" {\n                        $style = \"InLineView\"\n                    }\n                    Default {\n                        #fail safe action. This should never happen.\n                        Write-Warning \"Could not determine a view style. Are you running PSReadline v2.2.2 or later?\"\n                    }\n                } #nested switch\n            } #toggle\n        } #switch view\n\n        if ($style -AND ($PSCmdlet.ShouldProcess($style, \"Set prediction view style\"))) {\n            Set-PSReadLineOption -PredictionViewStyle $style\n            if ($Passthru) {\n                Get-PredictionView\n            }\n        }\n    } #try\n    Catch {\n        Write-Warning \"There was a problem. Could not determine a view style. Are you running PSReadline v2.2.2 or later? $($_.exception.message).\"\n    }\n} #end function<\/code><\/pre>\n\n\n\n<p>This code requires PSReadline version 2.2.2 or later. You can use the function to easily set a view style.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/set-predictionview.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"661\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/set-predictionview-1024x661.png\" alt=\"set-predictionview help\" class=\"wp-image-8972\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/set-predictionview-1024x661.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/set-predictionview-300x194.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/set-predictionview-768x496.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/set-predictionview-850x549.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/set-predictionview.png 1107w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>I set the default \"style\" to toggle between List and Inline. If I'm using List, the function will toggle the style to Inline and vice versa. Or I can explicitly set a style.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Set-predictionview List<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Get View Settings<\/h2>\n\n\n\n<p>Of course, if I'm setting something I should have a function to get something.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Get-PredictionView {\n    [cmdletbinding()]\n    [OutputType('PSPredictionView')]\n    [alias('gview')]\n    Param()\n\n    #define escape character based on PowerShell version\n    if ($IsCoreCLR) {\n        $e = '`e'\n    }\n    else {\n        $e = '[char]0x1b)'\n    }\n\n    #get prediction related PSReadline options\n    $options = Get-PSReadLineOption | Select-Object PredictionSource, PredictionViewStyle, ListPredictionColor,\n    ListPredictionSelectedColor, InlinePredictionColor\n\n    #create a new PSPredictionView object\n    [PSCustomObject]@{\n        PSTypeName        = \"PSPredictionView\"\n        Source            = $options.PredictionSource\n        Style             = $options.PredictionViewStyle\n        ListColor         = \"{0}$e{1}$([char]27)[0m\" -f $options.ListPredictionColor, ($options.ListPredictionColor -replace [char]27, \"\")\n        ListSelectedColor = \"{0}$e{1}$([char]27)[0m\" -f $options.ListPredictionSelectedColor, ($options.ListPredictionSelectedColor -replace [char]27, \"\")\n        InlineColor       = \"{0}$e{1}$([char]27)[0m\" -f $options.InlinePredictionColor, ($options.InlinePredictionColor -replace [char]27, \"\")\n    }\n\n} #end function<\/code><\/pre>\n\n\n\n<p>This function is called when running <code>Set-PredictionView -passthru<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/get-predictionview.png\"><img loading=\"lazy\" decoding=\"async\" width=\"378\" height=\"330\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/get-predictionview.png\" alt=\"get-predictionview\" class=\"wp-image-8973\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/get-predictionview.png 378w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/get-predictionview-300x262.png 300w\" sizes=\"auto, (max-width: 378px) 100vw, 378px\" \/><\/a><\/figure>\n\n\n\n<p>The functions have aliases which make them very easy to use from the console. With only a few keystrokes I can toggle between list and inline views. Talk about reducing friction!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>If you aren't using this PSReadline feature, you are missing out. I am aware that there is a potential security risk because the History option stores commands in a plain text file, so some people choose not to use it. But if you do, I hope you'll give these commands a try and let me know what you think.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Later that day...<\/h2>\n\n\n\n<p>I guess Microsoft must have also thought you might want to toggle between views. I never looked, but thanks to friends on Twitter, you can also press F2 to toggle between inline and list prediction views. I guess you don't really need my Set function unless you've re-mapped F2 to something else. You should run Get-PSReadlineKeyHandler to see what else you might be missing out on!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been using the PSReadline module for years in PowerShell. I especially loved it when the module added inline command prediction based on your history. You would start typing a command and the module would search your saved history and suggest an inline completion. In my PowerShell profile I enable and configure this feature. Recently,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New on the blog: #PowerShell Predictions with Style","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8],"tags":[176,534,587],"class_list":["post-8969","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-console","tag-powershell","tag-psreadline"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PowerShell Predicting with Style &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"I love it when PowerShell can read my mind. Here are a couple of functions that let me fine-tune PowerShell&#039;s command prediction from PSReadline.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PowerShell Predicting with Style &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I love it when PowerShell can read my mind. Here are a couple of functions that let me fine-tune PowerShell&#039;s command prediction from PSReadline.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-28T15:14:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-28T19:26:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/inline-prediction.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"PowerShell Predicting with Style\",\"datePublished\":\"2022-03-28T15:14:59+00:00\",\"dateModified\":\"2022-03-28T19:26:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/\"},\"wordCount\":460,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/inline-prediction.png\",\"keywords\":[\"console\",\"PowerShell\",\"PSReadLIne\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/\",\"name\":\"PowerShell Predicting with Style &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/inline-prediction.png\",\"datePublished\":\"2022-03-28T15:14:59+00:00\",\"dateModified\":\"2022-03-28T19:26:41+00:00\",\"description\":\"I love it when PowerShell can read my mind. Here are a couple of functions that let me fine-tune PowerShell's command prediction from PSReadline.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/inline-prediction.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/inline-prediction.png\",\"width\":581,\"height\":155},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8969\\\/powershell-predicting-with-style\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PowerShell Predicting with Style\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PowerShell Predicting with Style &#8226; The Lonely Administrator","description":"I love it when PowerShell can read my mind. Here are a couple of functions that let me fine-tune PowerShell's command prediction from PSReadline.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/","og_locale":"en_US","og_type":"article","og_title":"PowerShell Predicting with Style &#8226; The Lonely Administrator","og_description":"I love it when PowerShell can read my mind. Here are a couple of functions that let me fine-tune PowerShell's command prediction from PSReadline.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/","og_site_name":"The Lonely Administrator","article_published_time":"2022-03-28T15:14:59+00:00","article_modified_time":"2022-03-28T19:26:41+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/inline-prediction.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"PowerShell Predicting with Style","datePublished":"2022-03-28T15:14:59+00:00","dateModified":"2022-03-28T19:26:41+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/"},"wordCount":460,"commentCount":6,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/inline-prediction.png","keywords":["console","PowerShell","PSReadLIne"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/","name":"PowerShell Predicting with Style &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/inline-prediction.png","datePublished":"2022-03-28T15:14:59+00:00","dateModified":"2022-03-28T19:26:41+00:00","description":"I love it when PowerShell can read my mind. Here are a couple of functions that let me fine-tune PowerShell's command prediction from PSReadline.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/inline-prediction.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/03\/inline-prediction.png","width":581,"height":155},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"PowerShell Predicting with Style"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":9023,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9023\/powershell-first-timers\/","url_meta":{"origin":8969,"position":0},"title":"PowerShell First-Timers","author":"Jeffery Hicks","date":"May 11, 2022","format":false,"excerpt":"Are you a PowerShell first-timer? Someone who is finally dipping their toes into the PowerShell pool. Or maybe you want to poke around and see what all the fuss is about. If so, here are some steps you might want to take. Even if you've been using PowerShell for a\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/05\/pester-install-fail.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/05\/pester-install-fail.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/05\/pester-install-fail.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/05\/pester-install-fail.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":5721,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5721\/managing-the-psreadline-history-file\/","url_meta":{"origin":8969,"position":1},"title":"Managing the PSReadline History File","author":"Jeffery Hicks","date":"November 2, 2017","format":false,"excerpt":"It has taken some discipline but I have finally gotten the hang of using the command history file maintained by PSReadline. Even though Set-PSReadlineOption has a few options on how to use this file, in my experience I have felt the need to handle a few things on my own.\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8777,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/","url_meta":{"origin":8969,"position":2},"title":"Copy PowerShell History Command","author":"Jeffery Hicks","date":"January 11, 2022","format":false,"excerpt":"I thought I'd share a short but useful PowerShell utility. This is something that is very handy when I am writing. As you know, PowerShell maintains a command history in your PowerShell session. You can view history with the Get-History cmdlet or its alias h. To re-rerun a command use\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":6887,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6887\/creating-a-spooky-windows-terminal-theme\/","url_meta":{"origin":8969,"position":3},"title":"Creating a Spooky Windows Terminal Theme","author":"Jeffery Hicks","date":"October 29, 2019","format":false,"excerpt":"With Halloween fast arriving, I thought I'd share some more holiday-themed fun. Today's entry isn't necessarily PowerShell related but you might use it with your PowerShell work. If you've been kicking the tires on the Windows Terminal project from Microsoft, you might enjoy this. Here's the finished product and then\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/10\/image_thumb-10.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/10\/image_thumb-10.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/10\/image_thumb-10.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/10\/image_thumb-10.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":9325,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9325\/powershell-refresh\/","url_meta":{"origin":8969,"position":4},"title":"PowerShell Refresh","author":"Jeffery Hicks","date":"March 1, 2024","format":false,"excerpt":"The other day on X, I was asked about what things I would setup or configure on a new PowerShell installation. This is something I actually have thought about and face all the time when I setup a new demo virtual machine. I had been meaning to build new tooling\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8215,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/","url_meta":{"origin":8969,"position":5},"title":"PowerShell Property Sets to the Rescue","author":"Jeffery Hicks","date":"March 11, 2021","format":false,"excerpt":"if you are like me and spend most of your day at a PowerShell prompt, anything that simplifies that process is worth the time to learn or set up. Even though I am a decent typist, I am more than happy to find ways to type less at a PowerShell\u2026","rel":"","context":"In &quot;GitHub&quot;","block_context":{"text":"GitHub","link":"https:\/\/jdhitsolutions.com\/blog\/category\/github\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions2.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions2.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=8969"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8969\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}