<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Yet Another Linux Blog &#187; bash</title>
	<atom:link href="http://linux-blog.org/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://linux-blog.org</link>
	<description>Open Source, Open Blog</description>
	<lastBuildDate>Mon, 30 Aug 2010 14:18:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Adding Color to Bash List Command Part II</title>
		<link>http://linux-blog.org/adding-color-to-bash-list-command-part-ii/</link>
		<comments>http://linux-blog.org/adding-color-to-bash-list-command-part-ii/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 18:25:16 +0000</pubDate>
		<dc:creator>devnet</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[prompt]]></category>
		<category><![CDATA[tips and tricks]]></category>

		<guid isPermaLink="false">http://linux-blog.org/?p=1209</guid>
		<description><![CDATA[I previously blogged about how to add color to the &#8216;ls&#8217; command utilizing an config file and alias.  I then stumbled across a nugget of wisdom from a Foresight Linux user on the developers mailing list who gave a handy command that remedies some problems with missing color in a terminal. On some distributions, the [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I <a href="http://linux-blog.org/adding-color-to-bash-list-command/" target="_blank">previously blogged about how to add color to the &#8216;ls&#8217; command</a> utilizing an config file and alias.  I then stumbled across a nugget of wisdom from a Foresight Linux user on the developers mailing list who gave a handy command that remedies some problems with missing color in a terminal.</p>
<p>On some distributions, the system-wide <em>/etc/DIR_COLORS</em>* files are removed or not present.  This results in no colors being given inside of a terminal when looking for color directories and filenames.  If you find yourself in this boat, try the following command to re-populate this setting:</p>
<pre class="brush: bash;">devnet-&gt; cd ~/
devnet-&gt; dircolors -p &gt;.dircolors
</pre>
<p>This should create a default profile for colors for your session if it hasn&#8217;t been done or was accidentally removed.  For more information on the dircolors command try &#8216;man dircolors&#8217;.  Please also note that <em>dircolors</em> command uses the environmental variable LS_COLORS to set your session.</p>
<p>For more information on LS_COLORS and how it pertains to the terminal/shell/cli/prompt, there are a few blog posts that do an excellent job explaining <a href="http://twistedcode.blogspot.com/2008/04/lscolors-explained.html" target="_blank">here</a>, <a href="http://linux-sxs.org/housekeeping/lscolors.html" target="_blank">here</a> and <a href="http://www.bigsoft.co.uk/blog/index.php/2008/04/11/configuring-ls_colors" target="_blank">here</a>.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><p><a href="http://linux-blog.org/adding-color-to-bash-list-command-part-ii/" rel="bookmark">Adding Color to Bash List Command Part II</a> originally appeared on <a href="http://linux-blog.org">Yet Another Linux Blog</a> on September 8, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://linux-blog.org/adding-color-to-bash-list-command-part-ii/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adding Color to Bash List Command</title>
		<link>http://linux-blog.org/adding-color-to-bash-list-command/</link>
		<comments>http://linux-blog.org/adding-color-to-bash-list-command/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 21:00:06 +0000</pubDate>
		<dc:creator>devnet</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[prompt]]></category>
		<category><![CDATA[tips and tricks]]></category>

		<guid isPermaLink="false">http://linux-blog.org/?p=1067</guid>
		<description><![CDATA[One of the things I love is being able to enter into a directory via terminal, list the contents, and quickly see which ones are executable or not and which ones are directories or are not directories IN COLOR (not everyone is perfect right?).  This is specifically handy as I move through working with Slackware [...]


Related posts:<ol><li><a href='http://linux-blog.org/adding-color-to-bash-list-command-part-ii/' rel='bookmark' title='Permanent Link: Adding Color to Bash List Command Part II'>Adding Color to Bash List Command Part II</a> <small>I previously blogged about how to add color to the...</small></li>
<li><a href='http://linux-blog.org/convert-png-to-gif-via-command-line/' rel='bookmark' title='Permanent Link: Convert PNG to GIF via Command Line'>Convert PNG to GIF via Command Line</a> <small>I installed a bare bones Arch Linux system today and...</small></li>
<li><a href='http://linux-blog.org/installing-openbox-on-foresight-linux/' rel='bookmark' title='Permanent Link: Installing Openbox on Foresight Linux'>Installing Openbox on Foresight Linux</a> <small>My friend Og Maciel originally introduced me to Openbox a...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>One of the things I love is being able to enter into a directory via terminal, list the contents, and quickly see which ones are executable or not and which ones are directories or are not directories IN COLOR (not everyone is perfect right?).  This is specifically handy as I move through working with <a href="http://slackware.com">Slackware</a> based distributions like the one I&#8217;m using now, <a href="http://zenwalk.org">Zenwalk</a> Linux 6 and the <em>/etc/rc.d/</em> directory.  Most of the Red Hat based distributions out there that I&#8217;ve used have this set automatically&#8230;so I&#8217;m used to it.  When I opened up a terminal in Zenwalk I found no color. A quick investigation of <em>~/.bashrc</em> showed me that there are aliases set to display color&#8230;instead of ls I&#8217;d just use the letter L; 2 l&#8217;s for another option, 3 for another.  It&#8217;s interesting, but not normally how I do business.  See bashrc below:</p>
<pre class="brush: bash; highlight: [2,3,4];">
devnet[~]$ cat ~/.bashrc
alias lll=&quot;ls -al --color&quot;
alias ll=&quot;ls -l --color&quot;
alias l='ls --color'&lt;br /&gt;alias search='find . -name'
alias aterm=&quot;aterm -fg white -tr&quot;
alias version='cat /etc/zenwalk-version'
alias dh='df -h'&lt;br /&gt;export PS1='\u[\W]\$ '
export PAGER=&quot;most&quot;&lt;br /&gt;devnet[~]$
</pre>
<p>I don&#8217;t use those aliases much&#8230;others of you might do the &#8216;ll&#8217; or &#8216;lll&#8217; but it&#8217;s just not part of my routine.  So, I added in just after line 4 in the code above:</p>
<pre class="brush: bash;">
alias ls='ls --color'
</pre>
<p>You can do this a few different ways&#8230;with any command line editor like emacs, vi, or nano/pico.  It&#8217;s really up to you.  The easiest way for new users is to use a text editor:</p>
<pre class="brush: bash;">
devnet[~]$ mousepad ~/.bashrc
</pre>
<p>This will launch the mousepad text editor in XFCE.  If you&#8217;re in Gnome, try gedit.  If KDE, give kwrite a try.  You should see something like the following window pop up for editing:</p>
<p style="text-align: left;"><a href="http://linux-blog.org/wp-content/uploads/2009/06/bashrc.png"><img class="aligncenter size-full wp-image-1084" style="rel=&quot;lightbox&quot;" title="bashrc" src="http://linux-blog.org/wp-content/uploads/2009/06/bashrc.png" alt="bashrc" width="188" height="131" /></a>You should see in the picture above, I&#8217;ve added in the alias needed to make me comfortable.  After that, File &gt;&gt; Save.  You&#8217;re set!  Except, you may notice that when you type the command &#8216;ls&#8217; there are no colors.  So what gives?  Well, we haven&#8217;t loaded our <em>./bashrc</em> since we changed it.  You don&#8217;t have to logout and back in to get things to work though&#8230;you can do this right from the terminal:</p>
<pre class="brush: bash;">
devnet[~]$ exec bash
</pre>
<p>Now try giving the &#8216;ls&#8217; command a try again and you should see that it is in color.  I know a lot of the more advanced Linux guys out there are probably saying, &#8220;why&#8217;d he waste a post on this!  It&#8217;s easy&#8221; and you&#8217;d be right for a majority of users out there&#8230;I hope that this post finds some new user out there that may be stuck for an answer on how to do this.  One final note on this as well: You will have to do this as the root user and change <em>/root/.bashrc</em> in order for your root user to also have color.  Thanks for reading!<br />
<script type="text/javascript">// < ![CDATA[
google_ad_client = "pub-3982453702542240";
/* 468x15, created 6/24/09 */
google_ad_slot = "6181047080";
google_ad_width = 468;
google_ad_height = 15;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>


<p>Related posts:<ol><li><a href='http://linux-blog.org/adding-color-to-bash-list-command-part-ii/' rel='bookmark' title='Permanent Link: Adding Color to Bash List Command Part II'>Adding Color to Bash List Command Part II</a> <small>I previously blogged about how to add color to the...</small></li>
<li><a href='http://linux-blog.org/convert-png-to-gif-via-command-line/' rel='bookmark' title='Permanent Link: Convert PNG to GIF via Command Line'>Convert PNG to GIF via Command Line</a> <small>I installed a bare bones Arch Linux system today and...</small></li>
<li><a href='http://linux-blog.org/installing-openbox-on-foresight-linux/' rel='bookmark' title='Permanent Link: Installing Openbox on Foresight Linux'>Installing Openbox on Foresight Linux</a> <small>My friend Og Maciel originally introduced me to Openbox a...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><p><a href="http://linux-blog.org/adding-color-to-bash-list-command/" rel="bookmark">Adding Color to Bash List Command</a> originally appeared on <a href="http://linux-blog.org">Yet Another Linux Blog</a> on June 5, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://linux-blog.org/adding-color-to-bash-list-command/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Find Files &amp; Directories Not Visible to Others for Webserver</title>
		<link>http://linux-blog.org/find-files-directories-not-visible-to-others-webserver/</link>
		<comments>http://linux-blog.org/find-files-directories-not-visible-to-others-webserver/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 21:01:17 +0000</pubDate>
		<dc:creator>devnet</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[Webserver]]></category>

		<guid isPermaLink="false">http://linux-blog.org/?p=794</guid>
		<description><![CDATA[I wanted a quick way to be able to find out what files weren&#8217;t visible to others (and therefore, not visible to website visitors).  Messing with arguments and the file command, you can do the following: find -type f ! -perm -444 This locates all files not visible to &#8216;others&#8217; in the current directory.  You [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I wanted a quick way to be able to find out what files weren&#8217;t visible to others (and therefore, not visible to website visitors).  Messing with arguments and the <strong>file</strong> command, you can do the following:</p>
<pre>find -type f ! -perm -444</pre>
<p>This locates all files not visible to &#8216;others&#8217; in the current directory.  You can apply this to directories as well:</p>
<pre>find -type d ! -perm -111</pre>
<p>Hope this helps people like it helped me. <img src='http://linux-blog.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><p><a href="http://linux-blog.org/find-files-directories-not-visible-to-others-webserver/" rel="bookmark">Find Files &#038; Directories Not Visible to Others for Webserver</a> originally appeared on <a href="http://linux-blog.org">Yet Another Linux Blog</a> on November 25, 2008.</p>
]]></content:encoded>
			<wfw:commentRss>http://linux-blog.org/find-files-directories-not-visible-to-others-webserver/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>BASH Prompt Fun</title>
		<link>http://linux-blog.org/bash-prompt-fun/</link>
		<comments>http://linux-blog.org/bash-prompt-fun/#comments</comments>
		<pubDate>Wed, 15 Jun 2005 21:58:00 +0000</pubDate>
		<dc:creator>devnet</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tips and tricks]]></category>

		<guid isPermaLink="false">http://linux-blog.org/word/bash-prompt-fun/</guid>
		<description><![CDATA[The Bourne Again Shell aka BASH has been around for a while. For those of us that also have been around for a while&#8230;this shell possibly could be the one you choose to use for your Linux distro. I first started using BASH when I was in college. We had Solaris 2.0 Servers that allowed [...]


Related posts:<ol><li><a href='http://linux-blog.org/adding-color-to-bash-list-command-part-ii/' rel='bookmark' title='Permanent Link: Adding Color to Bash List Command Part II'>Adding Color to Bash List Command Part II</a> <small>I previously blogged about how to add color to the...</small></li>
<li><a href='http://linux-blog.org/convert-png-to-gif-via-command-line/' rel='bookmark' title='Permanent Link: Convert PNG to GIF via Command Line'>Convert PNG to GIF via Command Line</a> <small>I installed a bare bones Arch Linux system today and...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>The Bourne Again Shell aka <a title="BASH Homepage" href="http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html" target="_blank">BASH</a> has been around for a while.  For those of us that <em>also </em>have been around for a while&#8230;this shell possibly could be the one you choose to use for your Linux distro.  I first started using BASH when I was in college.  We had Solaris 2.0 Servers that allowed me to mess around quite a bit back then.</p>
<p>But most new users fear the shell (or as windows likes to call it, command line) and venture there as little as possible.  The prompt that greets most users that open a Linux shell is static and unyielding; yet, there are small adjustments that can make your Linux shell bend to the will of your force.  Today, I&#8217;ll be going over some simple and fun ways to alter your .bashrc file, which is where your BASH &#8220;profile&#8221; is kept and read each time you login.  Changes to this file can make your Linux shell a little bit friendly and less frightning.</p>
<p>Most shell&#8217;s look similar to this by default:</p>
<pre>[devnet@lostgate root]$</pre>
<p>This doesn&#8217;t do much for you other than tell you who you are, what your hostname is, and what directory you are in.  If you are like me, you want some useful information to be there so that what is above, becomes what is below:</p>
<pre><span style="color: #ff0000;">(</span><span style="color: #336666;">devnet@lostgate</span><span style="color: #ff0000;">:</span><span style="color: #336666;">/var/www/html</span><span style="color: #ff0000;">)</span><span style="color: #336666;">#</span></pre>
<p>Why is this so different?  For starters, after seeing how to add color to your prompt you&#8217;ll be able to add your own color scheme to things.  You&#8217;ll also be able to check out various ways to display information you want such as dates, times, whether you have mail, and your directory path you are in.  Do you need l33t programming skills to accomplish this?  Not at all!  If you&#8217;re ready, let&#8217;s give this thing a try&#8230;</p>
<p><span id="more-82"></span></p>
<p>To begin with, there are bash shell flags and options that allow you to customize your prompt. These are not unlike flags and options you may use in your everyday life. For example, whenever I schedule an appt. for morning, I put A.M. and for afternoon, I put P.M. I&#8217;m sure most of you have done this before as well. In this case, A.M. and P.M. stand for something else and signify something to YOU, the user. So, when we begin to look at customizing bash prompts, there are some letters and symbols that we can use to accomplish our goal.</p>
<p>First off, let&#8217;s find WHERE we need to go. Open up a Konsole, Shell, Xterm, or whatever you may call your terminal in your Linux distro. We will be altering a file that contains your bash profile that is read each time you login. For most Red Hat based distros it will be named .bashrc (yours may be different, such as .bash_profile&#8230;if you can&#8217;t find it yet, just follow along) however, you won&#8217;t be able to see it unless special options are selected. For me, using the shell (konsole) I&#8217;m able to use the following command to list the files in the current directory:</p>
<pre>%&gt; ls</pre>
<p>While this is nice, we need to get to the right directory first&#8230;kind of like going into and out of folders in Windows. So, to do this, let&#8217;s get to your home directory. Using the command &#8216;cd&#8217; which stands for &#8216;change directory&#8217; we can navigate to the right/correct folder/directory we need to work in.</p>
<pre>%&gt; cd /home/username</pre>
<p>Where username is YOUR username. In my case, it&#8217;s cd /home/devnet. So now, we&#8217;re in the correct directory where bashrc is located. Let&#8217;s list the files again.</p>
<pre>%&gt; ls</pre>
<p>Notice that you don&#8217;t see bashrc anywhere. This is because it is a system file. Just like Windows, you can&#8217;t always see system files. So, you need to add a &#8216;flag&#8217; to your list command. This &#8216;flag&#8217; operates just like a real flag does&#8230;a real flag would be flown outside your house or business and would mean something to someone and stand for something. In this case, our flag on our listing will also mean something&#8230;but it will mean something to us and the Linux operating system. Add the -a flag:</p>
<pre>%&gt; ls -a</pre>
<p>Now you should see .bashrc (notice the &#8216;dot&#8217; in front of it. All files with a dot in front can be found by adding the -a flag). If you&#8217;re using Kedit or Kate, you&#8217;ll have to change your view settings to see this file.</p>
<p>The bashrc file allows prompt string customization by using these backslash-escaped characters and color codes located beneath. Just like we used the -a flag to tell the list command what to do, you need to use the backslash to tell the bash prompt what to do:</p>
<pre><span style="font-size: x-small; color: #000000;">\a     an ASCII bell character (07)
\d     the  date  in  "Weekday  Month  Date" format (e.g., "Tue May 26")
\e     an ASCII escape character (033)
\h     the hostname up to the first `.'
\H     the hostname
\n     newline
\r     carriage return
\s     the name of the shell, the  basename  of  $0 (the portion following the final slash)
\t     the current time in 24_hour HH:MM:SS format
\T     the current time in 12_hour HH:MM:SS format
\@     the current time in 12_hour am/pm format
\u     the username of the current user
\v     the version of bash (e.g., 2.00)
\V     the  release  of  bash, version + patchlevel (e.g., 2.00.0)
\w     the current working directory
\W     the basename of the current  working  directory
\!     the history number of this command
\#     the command number of this command
\$     if  the effective UID is 0, a #, otherwise a $
\nnn   the character  corresponding to the octal number "nnn"
\\     a backslash
\[     begin a sequence of non_printing characters
\]     end a sequence of non_printing characters</span><span style="font-size: x-small; color: #ffffff;"><span style="color: #000000;">COLOR1="\[\033[0;36m\]"
COLOR2="\[\033[0;32m\]"
COLOR3="\[\033[0;36m\]"
COLOR4="\[\033[1;37m\]"</span></span></pre>
<p>For now, don&#8217;t worry about the above&#8230;especially the color stuff. That will give us easy ways to use color later on by allowing us to use COLOR4 instead of \033[1;37M\] everytime we needed to add some color to our prompt. Let&#8217;s continue on&#8230;just use the above as a reference. You&#8217;ll be able to use those \ designators to create a nice customized prompt. Ok, let&#8217;s get to cracking.</p>
<p>Open up your bash profile file that we spoke of earlier with your favorite text editor. For me, growing up on Solaris made me a pico and pine fan. Thus, I use the pico-like editor called nano for my editing.</p>
<pre>%&gt; nano .bashrc</pre>
<p>Now&#8230;don&#8217;t worry about anything that is already here in bashrc. Drop down beneath it and let&#8217;s try our first prompt out. Let&#8217;s give it some flags and color to make it like mine earlier in the article. Cut and past the COLOR1 through COLOR4 stuff in the reference table above into .bashrc. Now drop beneath that and let&#8217;s put a line for your prompt. You need to signify that you&#8217;re adding a prompt with the letters PS and the numeral 1. So, add the following line to .bashrc:</p>
<pre>PS1="$COLOR2($COLOR3\u@\h$COLOR2:$COLOR1\$PWD$COLOR1\\$ $COLOR4)"</pre>
<p>Notice the quotation marks contain all your color codes and flags. Now let&#8217;s decipher what we just did. In the above referenced COLOR1 through COLOR4 we assigned actual colors that bash can recognize to the words COLOR1, COLOR2, etc. That way, we only have to type the words COLOR1 instead of those long, drawn out code-like commands and flags. Next, notice the \u flag. If you refer above, you will see that \u displays the username of the user. Ok, so what are these $ signs? In order for us to use the colors, we got to show bash the money. Therefore, to tell it COLOR1 actually has a different value, we put a $ sign in front of it. Let&#8217;s continue on. Next up, an @ symbol. This is by itself and has no \ flags or $ signs. So, it is what it is. An &#8216;at&#8217; symbol. It will display as such. The same goes for the : in between $COLOR2 and $COLOR1. It&#8217;s a colon and it displays as such. Next up we have \\. Using the reference above, we see it is a backslash. So, we just displayed an extra backslash. Pretty simple eh?</p>
<p>Perhaps a different one using the same color scheme?  Try this one:</p>
<pre>PS1="$COLOR2($COLOR3\u@\h$COLOR2)-($COLOR1\@$COLOR2 $COLOR1\d$COLOR2)-($COLOR1\W$COLOR2)$COLOR1\n$COLOR1\\$ $COLOR4)"</pre>
<p>This one should display similar colors, but would display  like this:</p>
<pre><span style="color: #006633;">(</span><span style="color: #336666;">username@hostname</span><span style="color: #006633;">)-(</span><span style="color: #336666;">time &amp; date</span><span style="color: #006633;">)-(</span><span style="color: #336666;">basename directory</span><span style="color: #006633;">)</span></pre>
<p>Notice the \@ flags for current time in 12 hour format (non military). We&#8217;ve already been over the colors so you know what those mean. The rest is just referring up to the reference list above.</p>
<p>Another cool thing to do is to include a quick code for when you&#8217;re logged in as root:<br />
<code></p>
<pre class="brush: plain;">if [ &quot;$UID&quot; = &quot;0&quot; ];
then
# I am root
COLOR2=&quot;\[\033[0;31m\]&quot;
fi</pre>
<p></code></p>
<p>That turns COLOR2 to bright red to signify that you are root. You can include this underneath all your prompt stuff you just did. For instance, the last prompt we created would look like this using the code above:</p>
<pre><span style="color: #ff0000;">(</span><span style="color: #336666;">username@hostname</span><span style="color: #ff0000;">)-(</span><span style="color: #336666;">time &amp; date</span><span style="color: #ff0000;">)-(</span><span style="color: #336666;">basename directory</span><span style="color: #ff0000;">)</span></pre>
<p>Just cut and past it into your .bashrc and save.  The changes will take place next time you logon.</p>
<p>So, experiment around. Try it out. You can make things as complex as you want them or as simple as you want them. There are also more colors:</p>
<p>Black       0;30<br />
Dark Gray     1;30<br />
Blue        0;34<br />
Light Blue    1;34<br />
Green       0;32<br />
Light Green   1;32<br />
Cyan        0;36<br />
Light Cyan    1;36<br />
Red         0;31<br />
Light Red     1;31<br />
Purple      0;35<br />
Light Purple  1;35<br />
Brown       0;33<br />
Yellow        1;33<br />
Light Gray  0;37<br />
White         1;37</p>
<p>To place these codes above into more colors (say COLOR5, COLOR6, etc.) simply take what we had above and integrate it. So, we had COLOR1 set like this:</p>
<pre>COLOR1="\[\033[0;36m\]"</pre>
<p>Let&#8217;s put COLOR5 in as purple:</p>
<pre>COLOR5="\[\033[0;35m\]"</pre>
<p>Easy as pie. Don&#8217;t forget to include your quotation marks and quote marks in your prompts. Generally, quotes and quotations must be closed (meaning that if you have one you&#8217;ll need another). The number one error I had when first starting was messing up my quotation marks :p</p>
<p>After you&#8217;ve settled on a prompt you like&#8230;you&#8217;ll need to export that prompt aka display it for everyone to see, including yourself. So, if you set your prompt like this:</p>
<pre class="brush: plain;">PS1='\h:\w $'
export PS1</pre>
<p>The resulting prompt would look like this for me:</p>
<pre>lostgate:/home/devnet $</pre>
<p>Notice the &#8216;export PS1&#8242;. Ensure you put this directly after your PS1= stuff and you&#8217;ll be set. Now let&#8217;s close and save .bashrc. Now the next time you login, you&#8217;ll see your new prompt. You can test this out by trying the command su. For instance, say I was logged in as root and changed devnet&#8217;s .bashrc. Now I&#8217;ll log in as devnet to check it out:</p>
<pre>%&gt; su devnet</pre>
<p>Now I&#8217;m looking at my new improved prompt. If you aren&#8217;t root, you&#8217;ll be prompted for a password. But it&#8217;s better than logging out and logging back in. I hope this has been helpful to everyone.</p>
<p>If you have any questions with making your prompt or want to share some ultra cool wisdom on how you constructed your prompt with wicked awesome colors, please leave a comment on this article.</p>
<p>Thanks for reading and I hope this helps put some flavor on your bash prompt!</p>
<p>PS: Please post any errors you find with this article in the comments section and I&#8217;ll make the appropriate changes (with credit to those finding the errors <img src='http://linux-blog.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3982453702542240";
/* 468x15, created 6/24/09 */
google_ad_slot = "6181047080";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>


<p>Related posts:<ol><li><a href='http://linux-blog.org/adding-color-to-bash-list-command-part-ii/' rel='bookmark' title='Permanent Link: Adding Color to Bash List Command Part II'>Adding Color to Bash List Command Part II</a> <small>I previously blogged about how to add color to the...</small></li>
<li><a href='http://linux-blog.org/convert-png-to-gif-via-command-line/' rel='bookmark' title='Permanent Link: Convert PNG to GIF via Command Line'>Convert PNG to GIF via Command Line</a> <small>I installed a bare bones Arch Linux system today and...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><p><a href="http://linux-blog.org/bash-prompt-fun/" rel="bookmark">BASH Prompt Fun</a> originally appeared on <a href="http://linux-blog.org">Yet Another Linux Blog</a> on June 15, 2005.</p>
]]></content:encoded>
			<wfw:commentRss>http://linux-blog.org/bash-prompt-fun/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
