{"id":7929,"date":"2021-11-11T19:57:25","date_gmt":"2021-11-11T18:57:25","guid":{"rendered":"https:\/\/michlstechblog.info\/blog\/?p=7929"},"modified":"2021-11-12T11:49:02","modified_gmt":"2021-11-12T10:49:02","slug":"powershell-customize-the-prompt","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/powershell-customize-the-prompt\/","title":{"rendered":"Powershell: Customize the prompt"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_7929 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_7929')){$('.twoclick_social_bookmarks_post_7929').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Powershell%3A%20Customize%20the%20prompt\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Athe%20default%20prompt%20of%20the%20powershell%20is%20%22PS%22%20and%20the%20current%20working%20directory%3A%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/powershell-customize-the-prompt\\\/\",\"post_id\":7929,\"post_title_referrer_track\":\"Powershell%3A+Customize+the+prompt\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>the default prompt of the powershell is &#8220;PS&#8221; and the current working directory:<br \/>\n<!--more--><br \/>\n<!-- https:\/\/docs.microsoft.com\/de-de\/powershell\/module\/microsoft.powershell.core\/about\/about_prompts?view=powershell-7.2 --><\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nPS D:\\&gt; \r\n<\/pre>\n<p>This is set by the prompt function. With the Get-Command command let you can show the prompt functions script code:<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nPS D:\\&gt; Get-Command Prompt\r\nPS D:\\&gt; (Get-Command Prompt).ScriptBlock\r\n&quot;PS $($executionContext.SessionState.Path.CurrentLocation)$('&gt;' * ($nestedPromptLevel + 1)) &quot;;\r\n<\/pre>\n<p>To customize the prompt simply define an own function prompt. For example add a newline before the &#8220;>&#8221; <\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nfunction prompt()\r\n{\r\n    &quot;PS $($executionContext.SessionState.Path.CurrentLocation)$(&quot;`r`n&gt;&quot; * ($nestedPromptLevel + 1)) &quot;;\r\n}\r\n<\/pre>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, the default prompt of the powershell is &#8220;PS&#8221; and the current working directory:<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[344,5,4],"tags":[1653,1651,133,1652,20],"class_list":["post-7929","post","type-post","status-publish","format-standard","hentry","category-powershell-scripting","category-windowsknowhow","category-windowsscripts","tag-change-prompt","tag-customize","tag-powershell","tag-prompt","tag-windows-2"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/7929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=7929"}],"version-history":[{"count":1,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/7929\/revisions"}],"predecessor-version":[{"id":7930,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/7929\/revisions\/7930"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=7929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=7929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=7929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}