{"id":713,"date":"1997-09-09T01:36:29","date_gmt":"1997-09-09T09:36:29","guid":{"rendered":"http:\/\/www.birdhouse.org\/betips\/?p=2"},"modified":"1997-09-09T01:36:29","modified_gmt":"1997-09-09T09:36:29","slug":"customize-your-terminal-prompt","status":"publish","type":"post","link":"https:\/\/www.betips.net\/?p=713","title":{"rendered":"Customize your Terminal prompt"},"content":{"rendered":"<p>Open <code>\/boot\/home\/.profile<\/code> and scan down until you find a line that reads:<br \/>\nPS1=&#8217;$ &#8218;<br \/>\nEdit it so that it reads<br \/>\nPS1=&#8217;$PWD&gt; &#8218;<br \/>\nThe next time you open up Terminal, the prompt will report the current directory, no matter what you do. PWD is a Unix\/Be command meaning Print Working Directory &#8212; you&#8217;ve just told Terminal to print the working directory every time it displays a prompt. If you&#8217;re a migrating DOS person, you&#8217;ll welcome this extra bit of information.<br \/>\nIt should be pointed out that using the single quotes (&#8220;) are important. If you use double quotes (&#8222;&#8220;) instead, the prompt will be set to the current directory at the time of opening the terminal and then stay unchanged.<br \/>\nReason is that within double-quotes all variables like $PWD are evaluated immediately, whereas within single quotes they aren&#8217;t. That means:<br \/>\nPS1=&#8217;$PWD&gt; &#8218; -&gt; PS1 is in fact set to &#8218;$PWD&gt; &#8218;<br \/>\nPS1=&#8220;$PWD&gt; &#8220; -&gt; PS1 is in fact set to &#8218;\/boot\/home&gt; &#8218;<br \/>\nYou can further customize your prompt by including actual phrases, or anything you find useful or fun. For instance: \/boot\/home\/ &#8212; What&#8217;s up, cap&#8217;n? &gt;<br \/>\nThanks to <a href=\"mailto:lars@cableinet.co.uk\">Lars Duening<\/a> for the shell expansion details on this tip.<\/p>\n<hr \/>\n<p>Just Sherrill (justin@shiningsilence.com) adds this information:<br \/>\nBy setting parameters in your <code>.profile<\/code>, there are seemingly endless ways to customize your Terminal prompt.<br \/>\nFor example, inserting <code>PS1='$PWD'<\/code> will make your prompt display the current working directory, which can be handy. However, as you work farther down a set of directories, your prompt can end up taking most of the line.<br \/>\nInstead, the string <code>W<\/code> will print the name of the directory you are in, without the full path. You can even mix it with color commands. The following example gives you the current directory, without the path, but with a red colon at the end of the prompt.<br \/>\n<code>PS1='W\/?33[1;31m:?33[m '<\/code><br \/>\nThere are lots of other things you can include in your Terminal prompt, listed below: (stolen from <a href=\"http:\/\/doc.rmplc.co.uk\/linux\/LDP\/HOWTO\/Bash-Prompt-HOWTO-2.html\">http:\/\/d oc.rmplc.co.uk\/linux\/LDP\/HOWTO\/Bash-Prompt-HOWTO-2.html<\/a>, and probably available from many other places as well. Not all of these are useful yet on BeOS.)<\/p>\n<pre>       a     an ASCII bell character (07)\n       d     the  date  in  \"Weekday  Month  Date\" format  (e.g., \"Tue May 26\")\n       e     an ASCII escape character (033)\n       h     the hostname up to the first `.'\n       H     the hostname\n     newline\n     carriage return\n       s     the name of the shell, the  basename  of  $0  (the portion\n following the final slash)\n       \t     the current time in 24-hour HH:MM:SS format\n       T     the current time in 12-hour HH:MM:SS format\n       @     the current time in 12-hour am\/pm format\n       u     the username of the current user\n       v     the version of bash (e.g., 2.00)\n       V     the  release  of  bash, version + patchlevel (e.g., 2.00.0)\n       w     the current working directory\n       W     the basename of the current  working  directory\n       !     the history number of this command\n       #     the command number of this command\n       $     if  the effective UID is 0, a #, otherwise a $\nnn   the character  corresponding  to  the  octal number nnn\n       \\     a backslash\n       [     begin a sequence of non-printing characters,\n       which could be used to embed a terminal control sequence into the prompt\n       ]     end a sequence of non-printing characters<\/pre>\n<hr \/>\n<p>onyx m. reyes (onyx_reyes@yahoo.com) adds still more information:<br \/>\nThe prompt style has four elements: foreground color, background<br \/>\ncolor, effect (shadow or normal) and prompt script\/functions.<br \/>\nThe escape code template:<br \/>\n&#8218;e[X;Y;Z + m A&#8216; or &#8218;?33[X;Y;Z + m A&#8216;<br \/>\nthe escape code can be &#8222;e&#8220; or &#8222;?33&#8220; its your preference.<br \/>\nYou can arrange\/exclude X, Y, Z in any order and as long as they are<br \/>\nseperated with a &#8222;;&#8220; and the last value has an &#8222;m&#8220; after it.<br \/>\nExample:<br \/>\nps1=&#8217;e[40;01,37m $PWD e[m\/&gt;&#8216;<br \/>\nps1=&#8217;e[01;34m $PWD e[m\/&gt;&#8216;<br \/>\nUse the escape sequence every time you want a change the style of<br \/>\nthe prompt.<br \/>\nFinally, here is the list of colors codes and effects taken out<br \/>\nof my \/boot\/home\/.profile (you can cut and past this if you want)<\/p>\n<pre>PS1='[e[0;36;44m \t e[m] [e[0;34;46m $PWD e[m]\n[e[1;37;40m\nDarkStar e[m]-['<\/pre>\n<p>Some tips:<\/p>\n<ul>\n<li>using the same forground and background color will make it<br \/>\nreally hard to read.<\/li>\n<li>keep in mind that PS1 command will display spaces.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Open \/boot\/home\/.profile and scan down until you find a line that reads: PS1=&#8217;$ &#8218; Edit it so that it reads PS1=&#8217;$PWD&gt; &#8218; The next time you open up Terminal, the prompt will report the current directory, no matter what you do. PWD is a Unix\/Be command meaning Print Working Directory &#8212; you&#8217;ve just told Terminal [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[11],"class_list":["post-713","post","type-post","status-publish","format-standard","hentry","tag-terminal"],"_links":{"self":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/posts\/713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=713"}],"version-history":[{"count":0,"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/posts\/713\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}