<?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>non-random ramble &#187; linux commands</title>
	<atom:link href="http://jimbarritt.com/non-random/category/devops/linux-commands/feed/" rel="self" type="application/rss+xml" />
	<link>http://jimbarritt.com/non-random</link>
	<description>adventures in code</description>
	<lastBuildDate>Tue, 20 Sep 2011 13:16:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Colorised Build Success Message</title>
		<link>http://jimbarritt.com/non-random/2010/04/25/colorised-build-success-message/</link>
		<comments>http://jimbarritt.com/non-random/2010/04/25/colorised-build-success-message/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 18:05:16 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[linux commands]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/?p=450</guid>
		<description><![CDATA[My current project has a neat trick we picked up where the build has a red or green banner at the end when you run it locally to give good feedback about the build status. I&#8217;m not sure who originated it, but thanks! I just had to tweak it a bit to get it working [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jimbarritt.com/non-random/wp-content/uploads/2010/04/Build-Result.gif" rel="lightbox[450]"><img src="http://jimbarritt.com/non-random/wp-content/uploads/2010/04/Build-Result.gif" alt="" title="Build Result" width="681" height="248" class="aligncenter size-full wp-image-451" /></a></p>
<p>My current project has a neat trick we picked up where the build has a red or green banner at the end when you run it locally to give good feedback about the build status. I&#8217;m not sure who originated it, but thanks!</p>
<p>I just had to tweak it a bit to get it working on OS X so I thought I would document the trick here.</p>
<p><code>run.sh - OS X</code></p>
<pre name='code' class='java:nogutter:nocontrols'>
CMD=&#8221;./tools/ant/bin/ant -lib ./asl/lib/jdepend $@&#8221;
echo &#8220;Running command [${CMD}] &#8230;&#8221;
$CMD
if [ "$?" -ne 0 ]; then
    echo -e &#8220;`tput setab 1`  `cat ./ci/failed.txt` `tput setab 0`&#8221;
    exit 1
else
    echo -e &#8220;`tput setab 2`  `cat ./ci/passed.txt`  `tput setab 0`&#8221;
    exit 0
fi
</pre>
<p>This assumes you have two supporting files <code>./ci/passed.txt</code> and <code>./ci/failed.txt</code> which contain the message. You can generate messages to your taste <a href="http://www.network-science.de/ascii/">here</a>. </p>
<p>I have provided the files in this example here :</p>
<p><a href='http://jimbarritt.com/non-random/wp-content/uploads/2010/04/passed.txt'>passed.txt</a></p>
<p><a href='http://jimbarritt.com/non-random/wp-content/uploads/2010/04/failed.txt'>failed.txt</a></p>
<p>It has also been run under Ubuntu where the following works (it didnt work on OS X which is why I adapted it), but the <code>tput</code> should also work on Ubuntu. I&#8217;ve not explicitly tested this one!</p>
<pre name='code' class='java:nogutter:nocontrols'>
if [ "$?" -ne 0 ]; then
    echo -e &#8220;\E[30;41m"
    cat ./ci/failed.txt
    echo -e "\E[0m"
    exit 1
else
    echo -e "\E[30;42m"
    cat ./ci/passed.txt
    echo -e "\E[0m"
    exit 0
fi
</pre>
<p>Under windows you can actually make the entire screen of the terminal change color:</p>
<p><code>run.bat - WINDOWS</code></p>
<pre name='code' class='java:nogutter:nocontrols'>
CALL tools\ant\bin\ant %*
IF ERRORLEVEL 1 GOTO RedBuild
IF ERRORLEVEL 0 GOTO GreenBuild
:RedBuild
color 4F
GOTO TheEnd
:GreenBuild
color 2F
:TheEnd
PAUSE
color 07
</pre>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2010%2F04%2F25%2Fcolorised-build-success-message%2F&amp;title=Colorised%20Build%20Success%20Message" id="wpa2a_2"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2010/04/25/colorised-build-success-message/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check if an command was successful in bash</title>
		<link>http://jimbarritt.com/non-random/2009/09/03/check-if-an-command-was-successful-in-bash/</link>
		<comments>http://jimbarritt.com/non-random/2009/09/03/check-if-an-command-was-successful-in-bash/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 17:21:03 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[linux commands]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/2009/09/03/check-if-an-command-was-successful-in-bash/</guid>
		<description><![CDATA[When scripting gigantic build scripts with bash, its important that if anything fails you halt the script. Heres how: function checkResult() { RESULT=$1 if [ $RESULT -ne 0 ] ; then echo echo "!!!!!!!!!!! Build Failed !!!!!!!!!!!!!!!!!" echo exit $RESULT fi } You call it like this: ./someCommandOrScript.sh checkResult $?]]></description>
			<content:encoded><![CDATA[<p>When scripting gigantic build scripts with bash, its important that if anything fails you halt the script.</p>
<p>Heres how:</p>
<pre>
function checkResult() {
	RESULT=$1
	if [ $RESULT -ne 0 ] ; then
		echo
		echo "!!!!!!!!!!!  Build Failed !!!!!!!!!!!!!!!!!"
		echo
		exit $RESULT
	fi
}
</pre>
<p>You call it like this:</p>
<pre>
./someCommandOrScript.sh
checkResult $?
</pre>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2009%2F09%2F03%2Fcheck-if-an-command-was-successful-in-bash%2F&amp;title=Check%20if%20an%20command%20was%20successful%20in%20bash" id="wpa2a_4"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2009/09/03/check-if-an-command-was-successful-in-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iTerm &#8211; Upgrade your Terminal</title>
		<link>http://jimbarritt.com/non-random/2009/08/09/iterm-upgrade-your-terminal/</link>
		<comments>http://jimbarritt.com/non-random/2009/08/09/iterm-upgrade-your-terminal/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 10:51:30 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[linux commands]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[thoughtblog]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/2009/08/09/iterm-upgrade-your-terminal/</guid>
		<description><![CDATA[Spending a lot of time in various ssh sessions? A bit tired of trying to remember which tab is on which server with the default os x terminal ? So was I. Hunting around, I saw various hacks (e.g. a bash script, or applescript) to achieve this but also an app called iTerm. Its free [...]]]></description>
			<content:encoded><![CDATA[<p>Spending a lot of time in various ssh sessions?</p>
<p>A bit tired of trying to remember which tab is on which server with the default os x terminal ?</p>
<p>So was I. Hunting around, I saw various hacks (e.g. a <a href="http://pseudogreen.org/blog/set_tab_names_in_leopard_terminal.html">bash script</a>, or <a href="http://forums.macosxhints.com/showthread.php?t=58912">applescript</a>) to achieve this but also an app called <a href="http://iterm.sourceforge.net/">iTerm</a>.</p>
<p>Its free and within 30mins I was pretty much back to my previous terminal existence but with the names of my servers and my username in the tabs titles.</p>
<p>Awesome.</p>
<p>Some things I learned:</p>
<p>1) Some of the preferences I had to hunt for:</p>
<p>Not everything is available from iTerm&#8211;>Preferences. There are a couple of menu options of interest (this is iTerm 0.9.6).</p>
<p>View&#8211;>Show Session Info &#8230;</p>
<p>This lets you change the colors and fonts, etc for your terminal window and also update the default.</p>
<p>Bookmarks &#8211;> Manage Profiles &#8230;</p>
<p>This is where you can set a lot more options about your session, including making the cursor blink (Something for some reason I found essential:) </p>
<p>The reason they are here is because they are associated with bookmarks, a powerful feature that for example allows you to bookmark an ssh session, and have a whole set of preferences associated with that session.</p>
<p>I would like to see them all aggregated under the &#8220;Preferences&#8221; option though, because as a os x user, thats where I expect to find everything that I can configure (Posted as an <a href="https://sourceforge.net/tracker/?func=detail&#038;aid=2834416&#038;group_id=67789&#038;atid=518976">feature request</a>.</p>
<p>2) I wanted the title to change whenever I change directory. Simple, just need the following in my <code>~/.bash_profile</code> (see <a href="http://joshstaiger.org/archives/2005/07/bash_profile_vs.html">here</a> for differences between <code>~/.bashrc</code>:</p>
<pre>
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}: ${PWD/#$HOME/~}\007"'
</pre>
<p>3) This one is not probably very &#8220;good form&#8221;, but I really like the icon for the os x terminal window. So simply &#8220;Show Package Contents&#8221; on the iTerm.app and swap out <code>/Contents/Resources/iTerm.icns</code> with the equivalent in the Terminal application <code>Terminal.icns</code></p>
<p>4) I also wanted a &#8220;close x&#8221; icon on each tab, and discovered that this is under Preferences &#8211;> Tab &#8211;> Use compact tab labels. You want to UN check this.</p>
<p>I now have exactly the same user experience as before with some great bonuses, for example, a cool feature is the &#8220;blur&#8221; of the transparency behind the window. </p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2009%2F08%2F09%2Fiterm-upgrade-your-terminal%2F&amp;title=iTerm%20%E2%80%93%20Upgrade%20your%20Terminal" id="wpa2a_6"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2009/08/09/iterm-upgrade-your-terminal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Login message on unix</title>
		<link>http://jimbarritt.com/non-random/2009/08/08/login-message-on-unix/</link>
		<comments>http://jimbarritt.com/non-random/2009/08/08/login-message-on-unix/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 09:16:57 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[hosting]]></category>
		<category><![CDATA[linux commands]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/2009/08/08/login-message-on-unix/</guid>
		<description><![CDATA[I just learned how to put up a messages when you log in to a server&#8230; sudo vi /etc/motd its not a script so dont need to put &#8220;echo&#8221; just type what you want. For a cool ascii text generator, see http://asciiset.com/figletserver.html, I like banner3 as a font.]]></description>
			<content:encoded><![CDATA[<p>I just learned how to put up a messages when you log in to a server&#8230;</p>
<pre>
sudo vi /etc/motd
</pre>
<p>its not a script so dont need to put &#8220;echo&#8221; just type what you want.</p>
<p>For a cool ascii text generator, see <a href="http://asciiset.com/figletserver.html">http://asciiset.com/figletserver.html</a>, I like banner3 as a font.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2009%2F08%2F08%2Flogin-message-on-unix%2F&amp;title=Login%20message%20on%20unix" id="wpa2a_8"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2009/08/08/login-message-on-unix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sweet Search And Highlight Command</title>
		<link>http://jimbarritt.com/non-random/2007/07/15/sweet-search-and-highlight-command/</link>
		<comments>http://jimbarritt.com/non-random/2007/07/15/sweet-search-and-highlight-command/#comments</comments>
		<pubDate>Sat, 14 Jul 2007 17:40:49 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[linux commands]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/2007/07/15/sweet-search-and-highlight-command/</guid>
		<description><![CDATA[Been doing quite a bit of manipulating LaTeX files on the command line recently, and have a very sweet little command for searching for text in multiple files: grep -r Hoffman */*.tex &#124; less +/Hoffman Where &#8220;Hoffman&#8221; is the search term which can of course be any regular expression. The &#8220;less&#8221; command has a very [...]]]></description>
			<content:encoded><![CDATA[<p>Been doing quite a bit of manipulating LaTeX files on the command line recently, and have a very sweet little command for searching for text in multiple files:</p>
<p><code>grep -r Hoffman */*.tex | less +/Hoffman</code></p>
<p>Where &#8220;Hoffman&#8221; is the search term which can of course be any regular expression.</p>
<p>The &#8220;less&#8221; command has a very convenient argument &#8220;+&#8221; which allows you to pass a search term in and will automatically highlight it for you.</p>
<p>The -r in grep recurses directories and */*.tex looks for all tex files. the | pipes the result to less.</p>
<p>sweet.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2007%2F07%2F15%2Fsweet-search-and-highlight-command%2F&amp;title=Sweet%20Search%20And%20Highlight%20Command" id="wpa2a_10"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2007/07/15/sweet-search-and-highlight-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

