{"id":147,"date":"2007-06-11T15:00:00","date_gmt":"2007-06-11T23:00:00","guid":{"rendered":"http:\/\/testblog.sapien.com\/index.php\/2007\/06\/11\/more-fun-with-prompts\/"},"modified":"2007-06-11T15:00:00","modified_gmt":"2007-06-11T23:00:00","slug":"more-fun-with-prompts","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2007\/06\/11\/more-fun-with-prompts\/","title":{"rendered":"More fun with prompts"},"content":{"rendered":"<p>Here&#8217;s some more fun you can have with your PowerShell prompt. Hopefully you caught my earlier <a href=\"\/current\/2007\/6\/6\/do-you-need-some-prompting.html\">post<\/a> on this topic. Let&#8217;s continue. One thing you may not realize about Powershell, is that the native format is Unicode. This means you can display Unicode characters in your prompt.<\/p>\n<p>To display a Unicode character you need to know its code number. Open Character Map (Start &#8211; Run &#8211; Charmap).&nbsp; As you hover your mouse over a character you will see something like U+0040. That is the code number.&nbsp; To use that number in PowerShell type<\/p>\n<p><font style=\"color: #0000ff\" face=\"Lucida Console\" color=\"#0000ff\">PS C:\\&gt; [char]0x0040<\/font><\/p>\n<p>What you&#8217;re doing is replacing U+ with 0x so that you&#8217;ve typed a hex value. <\/p>\n<p>You should get the @ symbol. Big deal.&nbsp; I can type the character from the keyboard. But there are many other characters you can use that aren&#8217;t on the keyboard.&nbsp; Try these expressions out:<\/p>\n<p><font style=\"color: #0000ff\" face=\"Lucida Console\" color=\"#0000ff\">PS C:\\&gt; [char]0x00b6<\/font><\/p>\n<p><font style=\"color: #0000ff\" face=\"Lucida Console\" color=\"#0000ff\">PS C:\\&gt; [char]0x25ba<\/font><\/p>\n<p><font style=\"color: #0000ff\" face=\"Lucida Console\" color=\"#0000ff\">PS C:\\&gt; [char]0x25c4<\/font><\/p>\n<p><font style=\"color: #0000ff\" face=\"Lucida Console\" color=\"#0000ff\">PS C:\\&gt; [char]0x25bc<\/font><\/p>\n<p><font style=\"color: #0000ff\" face=\"Lucida Console\" color=\"#0000ff\">PS C:\\&gt; [char]0x25b2<\/font><\/p>\n<p>Do you see where I&#8217;m going with this? Now you can have a prompt that has a little something extra like this:<\/p>\n<p><font style=\"color: #0000ff\" face=\"lucida consol\" color=\"#0000ff\">Function prompt {<br \/>#PSH S:\\PoSH &lt;green right pointing triangle&gt;<br \/>Write-Host &#8220;PSH $(get-location) &#8221; -nonewline -fore yellow<br \/>Write-Host ([char]0x25ba) -fore Green -nonewline<br \/>Return &#8221; &#8220;<br \/>&nbsp;}<\/font> <\/p>\n<p>This will give you a prompt like this:<\/p>\n<table>\n<tbody>\n<tr>\n<td bgcolor=\"#000066\"><font style=\"color: #ffff00\" color=\"#ffff00\">PSH J:\\WindowsPowerShell<\/font> <font style=\"color: #008000\" color=\"#008000\">\u25ba<\/font><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>(The color doesn&#8217;t display nicely, sorry.)<\/p>\n<p>With Unicode I can draw boxes so what about displaying a prompt like this:<\/p>\n<p><font style=\"color: #008040\" color=\"#008040\">\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\u2502PSH 6\/8\/2007 1:19 PM J:\\WindowsPowerShell &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502<br \/>\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518-&gt;<\/font> <\/p>\n<p>The formatting is a little off when copied here, but you get the idea. I&#8217;ve attached the functions so you don&#8217;t have to try and copy.&nbsp; I&#8217;ve got one more major prompt idea but I&#8217;ll save that for later. <\/p>\n<div class=\"wlWriterSmartContent\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:e03a45e7-a61b-4e06-8b10-53648f65563c\" style=\"padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px\">del.icio.us Tags: <a href=\"http:\/\/del.icio.us\/popular\/Powershell\" rel=\"tag\">Powershell<\/a>, <a href=\"http:\/\/del.icio.us\/popular\/Prompt\" rel=\"tag\">Prompt<\/a>, <a href=\"http:\/\/del.icio.us\/popular\/Unicode\" rel=\"tag\">Unicode<\/a>, <a href=\"http:\/\/del.icio.us\/popular\/Get-Location\" rel=\"tag\">Get-Location<\/a><\/div>\n<p><\/p>\n<div class=\"wlWriterSmartContent\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:4bb8b3c4-15a0-4e48-b7ec-0126c1e2a94f\" style=\"padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px\">Technorati Tags: <a href=\"http:\/\/technorati.com\/tags\/PowerShell\" rel=\"tag\">PowerShell<\/a>, <a href=\"http:\/\/technorati.com\/tags\/Prompt\" rel=\"tag\">Prompt<\/a>, <a href=\"http:\/\/technorati.com\/tags\/Unicode\" rel=\"tag\">Unicode<\/a>, <a href=\"http:\/\/technorati.com\/tags\/Get-Location\" rel=\"tag\">Get-Location<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s some more fun you can have with your PowerShell prompt. Hopefully you caught my earlier post on this topic. Let&#8217;s continue. One thing you may not realize about Powershell, is that the native format is Unicode. This means you can display Unicode characters in your prompt.<\/p>\n","protected":false},"author":3,"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,"footnotes":""},"categories":[25],"tags":[],"class_list":["post-147","post","type-post","status-publish","format-standard","hentry","category-windows-powershell"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=147"}],"version-history":[{"count":0,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/147\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}