{"id":1191,"date":"2010-07-26T21:26:02","date_gmt":"2010-07-26T12:26:02","guid":{"rendered":"http:\/\/livedevil.net\/?p=1191"},"modified":"2010-07-26T21:26:02","modified_gmt":"2010-07-26T12:26:02","slug":"powershell-customize-prompt","status":"publish","type":"post","link":"https:\/\/talsu.net\/?p=1191","title":{"rendered":"Powershell &#8211; Customize prompt"},"content":{"rendered":"<p>Powershell \uc758 Prompt\ub294 \uae30\ubcf8\uc801\uc73c\ub85c PS {\ud604\uc7ac\uacbd\ub85c}>  \ub85c \ub418\uc5b4 \uc788\ub2e4.<\/p>\n<p>\uc774 \ubaa8\uc591\uc740 Powershell \uc5d0\uc11c \uba85\ub839\uc744 \uc218\ud589\ud558\uace0 Prompt \ub77c\ub294 Function\uc744 \uc218\ud589\ud55c \uacb0\uacfc\uc774\ub2e4.<\/p>\n<p>\ubbff\uae30\uc9c0 \uc54a\ub294 \ub2e4\uba74 \ub2e4\uc74c \uba85\ub839\uc73c\ub85c \ud655\uc778 \ud574 \ubcf4\uc790.<\/p>\n<pre class=\"lang:default decode:true\">\nGet-Command prompt\n<\/pre>\n<p>\ub2e4\uc74c\uacfc \uac19\uc774 Fuction\uc784\uc744 \ud655\uc778 \ud560 \uc218 \uc788\uc744 \uac83\uc774\ub2e4.<\/p>\n<pre class=\"lang:default decode:true\">\nCommandType Name   Definition\n----------- ----   ----------\nFunction    prompt $(if (test-path variable:\/PSDebugCon...\n<\/pre>\n<p>Definition\uc744  \uc790\uc138\ud788 \ubcf4\uba74 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class=\"lang:ps decode:true\">\n$(\n \tif (test-path variable:\/PSDebugContext)\n\t{\n\t\t'[DBG]: '\n\t}\n\telse\n\t{\n\t\t''\n\t}\n) + 'PS ' + $(Get-Location) +\n$(\n\tif ($nestedpromptlevel -ge 1)\n\t{\n\t\t'>>'\n\t}\n) + '> '\n<\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\uac00 Powershell\uc758 Prompt\ub97c \uc4f0\ub294 \uac83\uc774\ub2e4.<\/p>\n<p>\uadf8\ub7ec\ubbc0\ub85c \ub611\uac19\uc740 \uc774\ub984\uc758 Prompt Function\uc744 \ub9cc\ub4e4\uba74 \uc9c1\uc811 \ub9cc\ub4e0 Prompt\ub97c \uc0ac\uc6a9 \ud560 \uc218 \uc788\ub2e4.<\/p>\n<p>\uc608\ub97c \ub4e4\uc5b4 PS \ub77c\ub294 \ubb38\uc790 \ub300\uc2e0\uc5d0 \uc790\uc2e0\uc758 Username \uc744 \ub123\uace0 \uc2f6\ub2e4\uba74<\/p>\n<pre class=\"lang:ps decode:true\">\nFunction Prompt{\n\t$(\n\t\tif (test-path variable:\/PSDebugContext)\n\t\t{\n\t\t\t'[DBG]: '\n\t\t}\n\t\telse\n\t\t{\n\t\t\t''\n\t\t}\n\t) + $Env:USERNAME + ' ' + $(Get-Location) +\n\t$(\n\t\tif ($nestedpromptlevel -ge 1)\n\t\t{\n\t\t\t'>>'\n\t\t}\n\t) + '> '\n}\n<\/pre>\n<p><img src=\"wp-content\/uploads\/2010\/07\/PromptChange1.png\" alt=\"Powershell Prompt Username\" \/><\/p>\n<p>\uc0ac\uc6a9\uc790 \uc774\ub984\uc774 \uc798 \ubcf4\uc778\ub2e4.<\/p>\n<p>\ud55c\uac00\uc9c0\ub9cc \ub354 \ud574\ubcf4\uc790, \uc751\uc6a9\ud558\uba74 \ub354\uc6b1 \uc7ac\ubbf8 \uc788\uac8c \uc4f8 \uc218 \uc788\ub2e4. \uaf2d Prompt \ub9cc \ubcc0\uacbd \ud560\uc218 \uc788\ub2e4\uace0 \uc0dd\uac01 \ud558\uc9c0 \ub9d0\uc790 $host.UI \ub97c \uc774\uc6a9\ud558\uc5ec Window Title \uc744 \ud604\uc7ac \uacbd\ub85c\ub85c \ud560 \uc218\ub3c4 \uc788\ub2e4.<\/p>\n<pre class=\"lang:ps decode:true\">\nfunction Prompt\n{\n\t$Colors = [System.Enum]::GetValues([System.ConsoleColor])\n\t$Color = $Colors[$(Get-Random -Minimum 0 -Max ($Colors.Count))]\n\tWrite-Host -ForegroundColor $Color \"PS\" -NoNewline\n\tWrite-Host -NoNewLine \" $(Get-Location)>  \"\n\t$host.UI.RawUI.WindowTitle = \"$(Get-Location)\"\n\t\"`b\"\n}\n<\/pre>\n<p><img src=\"wp-content\/uploads\/2010\/07\/PromptChangeColor.png\" alt=\"Prompt Color\" \/><\/p>\n<p>\uc7ac\ubbf8 \uc0bc\uc544 PS \uae00\uc790\uc758 \uc0c9\uc744 Random \ud558\uac8c \ub123\uc5b4 \ubd24\ub294\ub370 \ubcc4\ub85c \uc774\uc058\uc9c0\ub3c4 \uc54a\uace0 \uba4d\uccad\ud574 \ubcf4\uc778\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Powershell \uc758 Prompt\ub294 \uae30\ubcf8\uc801\uc73c\ub85c PS {\ud604\uc7ac\uacbd\ub85c}> \ub85c \ub418\uc5b4 \uc788\ub2e4. \uc774 \ubaa8\uc591\uc740 Powershell \uc5d0\uc11c \uba85\ub839\uc744 \uc218\ud589\ud558\uace0 Prompt \ub77c\ub294 Function\uc744 \uc218\ud589\ud55c \uacb0\uacfc\uc774\ub2e4. \ubbff\uae30\uc9c0 \uc54a\ub294 \ub2e4\uba74 \ub2e4\uc74c \uba85\ub839\uc73c\ub85c \ud655\uc778 \ud574 \ubcf4\uc790. Get-Command prompt \ub2e4\uc74c\uacfc \uac19\uc774 Fuction\uc784\uc744 \ud655\uc778 \ud560 \uc218 \uc788\uc744 \uac83\uc774\ub2e4. CommandType Name Definition &#8212;&#8212;&#8212;&#8211; &#8212;- &#8212;&#8212;&#8212;- Function prompt $(if (test-path variable:\/PSDebugCon&#8230; Definition\uc744 \uc790\uc138\ud788 \ubcf4\uba74 \ub2e4\uc74c\uacfc \uac19\ub2e4. $( [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[25,26],"tags":[28,30,75,481,204,209,273],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pXV5a-jd","_links":{"self":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts\/1191"}],"collection":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1191"}],"version-history":[{"count":0,"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts\/1191\/revisions"}],"wp:attachment":[{"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}