<?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>Linux 101 Hacks &#187; 06. Colorful Shell Prompt Using PS1</title>
	<atom:link href="http://linux.101hacks.com/category/ps1-examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://linux.101hacks.com</link>
	<description>Free eBook to Build a Strong Foundation in UNIX / Linux</description>
	<lastBuildDate>Fri, 09 Dec 2011 06:07:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Hack 43. Use shell script inside PS1 variable</title>
		<link>http://linux.101hacks.com/ps1-examples/shell-script-in-ps1/</link>
		<comments>http://linux.101hacks.com/ps1-examples/shell-script-in-ps1/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 16:20:30 +0000</pubDate>
		<dc:creator>Ramesh</dc:creator>
				<category><![CDATA[06. Colorful Shell Prompt Using PS1]]></category>

		<guid isPermaLink="false">http://linux.101hacks.com/?p=172</guid>
		<description><![CDATA[You can also invoke a shell script inside the PS1 variable. In the example below, the ~/bin/totalfilesize.sh, which calculates the total filesize of the current directory, is invoked inside the PS1 variable. ramesh@dev-db ~> cat ~/bin/totalfilesize.sh for filesize in $(ls -l . &#124; grep "^-" &#124; awk '{print $5}') do let totalsize=$totalsize+$filesize done echo -n [...]]]></description>
		<wfw:commentRss>http://linux.101hacks.com/ps1-examples/shell-script-in-ps1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hack 42. Use bash shell function inside PS1 variable</title>
		<link>http://linux.101hacks.com/ps1-examples/bash-shell-function-in-ps1/</link>
		<comments>http://linux.101hacks.com/ps1-examples/bash-shell-function-in-ps1/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 16:18:50 +0000</pubDate>
		<dc:creator>Ramesh</dc:creator>
				<category><![CDATA[06. Colorful Shell Prompt Using PS1]]></category>

		<guid isPermaLink="false">http://linux.101hacks.com/?p=170</guid>
		<description><![CDATA[You can also invoke a bash shell function in the PS1 as shown below. ramesh@dev-db ~> function httpdcount { > ps aux &#124; grep httpd &#124; grep -v grep &#124; wc -l > } ramesh@dev-db ~> export PS1="\u@\h [`httpdcount`]> " ramesh@dev-db [12]> [Note: This displays the total number of running httpd processes] You can add [...]]]></description>
		<wfw:commentRss>http://linux.101hacks.com/ps1-examples/bash-shell-function-in-ps1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hack 41. Create your own prompt using the available codes for PS1 variable</title>
		<link>http://linux.101hacks.com/ps1-examples/cutomize-your-prompt/</link>
		<comments>http://linux.101hacks.com/ps1-examples/cutomize-your-prompt/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 16:16:51 +0000</pubDate>
		<dc:creator>Ramesh</dc:creator>
				<category><![CDATA[06. Colorful Shell Prompt Using PS1]]></category>

		<guid isPermaLink="false">http://linux.101hacks.com/?p=168</guid>
		<description><![CDATA[Use the following codes and create your own personal PS1 Linux prompt that is functional and suites your taste. \a an ASCII bell character (07) \d the date in “Weekday Month Date” format (e.g., “Tue May 26?) \D{format} &#8211; the format is passed to strftime(3) and the result is inserted into the prompt string; an [...]]]></description>
		<wfw:commentRss>http://linux.101hacks.com/ps1-examples/cutomize-your-prompt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hack 40. Change the prompt color using tput</title>
		<link>http://linux.101hacks.com/ps1-examples/prompt-color-using-tput/</link>
		<comments>http://linux.101hacks.com/ps1-examples/prompt-color-using-tput/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 16:13:41 +0000</pubDate>
		<dc:creator>Ramesh</dc:creator>
				<category><![CDATA[06. Colorful Shell Prompt Using PS1]]></category>

		<guid isPermaLink="false">http://linux.101hacks.com/?p=166</guid>
		<description><![CDATA[You can also change color of the PS1 prompt using tput as shown below: $ export PS1="\[$(tput bold)$(tput setb 4)$(tput setaf 7)\]\u@\h:\w $ \[$(tput sgr0)\]“ tput Color Capabilities: tput setab [1-7] &#8211; Set a background color using ANSI escape tput setb [1-7] &#8211; Set a background color tput setaf [1-7] &#8211; Set a foreground color [...]]]></description>
		<wfw:commentRss>http://linux.101hacks.com/ps1-examples/prompt-color-using-tput/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hack 39. Display multiple colors in the prompt</title>
		<link>http://linux.101hacks.com/ps1-examples/prompt-in-multiple-color/</link>
		<comments>http://linux.101hacks.com/ps1-examples/prompt-in-multiple-color/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 16:10:32 +0000</pubDate>
		<dc:creator>Ramesh</dc:creator>
				<category><![CDATA[06. Colorful Shell Prompt Using PS1]]></category>

		<guid isPermaLink="false">http://linux.101hacks.com/?p=164</guid>
		<description><![CDATA[You can also display multiple colors in the same prompt. Add the following function to your ~/.bash_profile function prompt { local BLUE="\[\033[0;34m\]" local DARK_BLUE="\[\033[1;34m\]” local RED=”\[\033[0;31m\]” local DARK_RED=”\[\033[1;31m\]” local NO_COLOR=”\[\033[0m\]” case $TERM in xterm*&#124;rxvt*) TITLEBAR=’\[\033]0;\u@\h:\w\007\]’ ;; *) TITLEBAR=”" ;; esac PS1=”\u@\h [\t]> ” PS1=”${TITLEBAR}\ $BLUE\u@\h $RED[\t]>$NO_COLOR ” PS2=’continue-> ‘ PS4=’$0.$LINENO+ ‘ } You can re-login [...]]]></description>
		<wfw:commentRss>http://linux.101hacks.com/ps1-examples/prompt-in-multiple-color/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hack 38. Change background color of the prompt</title>
		<link>http://linux.101hacks.com/ps1-examples/change-prompt-background-color/</link>
		<comments>http://linux.101hacks.com/ps1-examples/change-prompt-background-color/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 16:08:53 +0000</pubDate>
		<dc:creator>Ramesh</dc:creator>
				<category><![CDATA[06. Colorful Shell Prompt Using PS1]]></category>

		<guid isPermaLink="false">http://linux.101hacks.com/?p=162</guid>
		<description><![CDATA[Change the background color by specifying \e[{code}m in the PS1 prompt as shown below. $ export PS1="\e[47m\u@\h \w&#62; \e[m " [Note: This is for Light Gray background] Combination of background and foreground. $ export PS1="\e[0;34m\e[47m\u@\h \w&#62; \e[m " [Note: This is for Light Blue foreground and Light Gray background] Add the following to your ~/.bash_profile [...]]]></description>
		<wfw:commentRss>http://linux.101hacks.com/ps1-examples/change-prompt-background-color/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hack 37. Change foreground color of the prompt</title>
		<link>http://linux.101hacks.com/ps1-examples/change-prompt-foreground-color/</link>
		<comments>http://linux.101hacks.com/ps1-examples/change-prompt-foreground-color/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 16:06:21 +0000</pubDate>
		<dc:creator>Ramesh</dc:creator>
				<category><![CDATA[06. Colorful Shell Prompt Using PS1]]></category>

		<guid isPermaLink="false">http://linux.101hacks.com/?p=159</guid>
		<description><![CDATA[Display prompt in blue color, along with username, host and current directory information $ export PS1="\e[0;34m\u@\h \w&#62; \e[m " [Note: This is for light blue prompt] $ export PS1="\e[1;34m\u@\h \w&#62; \e[m " [Note: This is for dark blue prompt] \e[ - Indicates the beginning of color prompt x;ym - Indicates color code. Use the color [...]]]></description>
		<wfw:commentRss>http://linux.101hacks.com/ps1-examples/change-prompt-foreground-color/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hack 36. Display output of any command in the prompt</title>
		<link>http://linux.101hacks.com/ps1-examples/command-output-in-prompt/</link>
		<comments>http://linux.101hacks.com/ps1-examples/command-output-in-prompt/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 16:03:29 +0000</pubDate>
		<dc:creator>Ramesh</dc:creator>
				<category><![CDATA[06. Colorful Shell Prompt Using PS1]]></category>

		<guid isPermaLink="false">http://linux.101hacks.com/?p=157</guid>
		<description><![CDATA[You can display output of any Linux command in the prompt. The following example displays three items separated by &#124; (pipe) in the command prompt: \!: The history number of the command \h: hostname $kernel_version: The output of the uname -r command from $kernel_version variable \$?: Status of the last command ramesh@dev-db ~&#62; kernel_version=$(uname -r) [...]]]></description>
		<wfw:commentRss>http://linux.101hacks.com/ps1-examples/command-output-in-prompt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hack 35. Display current time in the prompt</title>
		<link>http://linux.101hacks.com/ps1-examples/current-date-and-time-in-prompt/</link>
		<comments>http://linux.101hacks.com/ps1-examples/current-date-and-time-in-prompt/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 16:00:12 +0000</pubDate>
		<dc:creator>Ramesh</dc:creator>
				<category><![CDATA[06. Colorful Shell Prompt Using PS1]]></category>

		<guid isPermaLink="false">http://linux.101hacks.com/?p=153</guid>
		<description><![CDATA[In the PS1 environment variable, you can directly execute any Linux command, by specifying in the format $(linux_command). In the following example, the command $(date) is executed to display the current time inside the prompt. ramesh@dev-db ~> export PS1="\u@\h [\$(date +%H:%M:%S)]> " ramesh@dev-db [11:09:56]> You can also use \t to display the current time in [...]]]></description>
		<wfw:commentRss>http://linux.101hacks.com/ps1-examples/current-date-and-time-in-prompt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hack 34. Display username, hostname and basename of directory in the prompt</title>
		<link>http://linux.101hacks.com/ps1-examples/display-user-host-dir-name/</link>
		<comments>http://linux.101hacks.com/ps1-examples/display-user-host-dir-name/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 15:53:42 +0000</pubDate>
		<dc:creator>Ramesh</dc:creator>
				<category><![CDATA[06. Colorful Shell Prompt Using PS1]]></category>

		<guid isPermaLink="false">http://linux.101hacks.com/?p=149</guid>
		<description><![CDATA[The PS1 in this example displays following three information in the prompt: \u – Username \h – Hostname \W – Base name of the current working directory -bash-3.2$ export PS1="\u@\h \W&#62; " ramesh@dev-db ~&#62; cd /etc/mail ramesh@dev-db mail&#62; In this example, the Linux prompt changed from the boring &#8220;-bash-3.2$&#8221; to a meaningful &#8220;ramesh@dev-db mail&#62;&#8221;, in [...]]]></description>
		<wfw:commentRss>http://linux.101hacks.com/ps1-examples/display-user-host-dir-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Content Delivery Network via Amazon Web Services: CloudFront: static.101hacks.com

Served from: linux.101hacks.com @ 2012-02-04 04:05:34 -->
