<?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>Blog.ubrious &#187; bash</title>
	<atom:link href="http://blog.ubrio.us/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ubrio.us</link>
	<description>An Ordinary Web Developer's Blog</description>
	<lastBuildDate>Thu, 19 Jan 2012 00:44:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>OSX, RubyGems and cross-thread violations in rb_gc</title>
		<link>http://blog.ubrio.us/nix/osx-rubygems-and-cross-thread-violations-in-rb_gc/</link>
		<comments>http://blog.ubrio.us/nix/osx-rubygems-and-cross-thread-violations-in-rb_gc/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 15:37:40 +0000</pubDate>
		<dc:creator>Rob Hurring</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Nix]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[gems]]></category>

		<guid isPermaLink="false">http://blog.ubrio.us/?p=104</guid>
		<description><![CDATA[I recently decided to migrate away from OSX&#8217;s default ruby install yesterday and noticed a few quirky hangups. Firstly, for some reason, and I&#8217;m not sure if it is just me or not, OSX&#8217;s default $PATH variable is putting /usr/local/bin AFTER /bin making your local installs not enabled by default. (Editing the /etc/paths didn&#8217;t do [...]]]></description>
			<content:encoded><![CDATA[<p>I recently decided to migrate away from OSX&#8217;s default ruby install yesterday and noticed a few quirky hangups. Firstly, for some reason, and I&#8217;m not sure if it is just me or not, OSX&#8217;s default $PATH variable is putting /usr/local/bin AFTER /bin making your local installs not enabled by default. (Editing the /etc/paths didn&#8217;t do the trick so I manually added it to PATH).</p>
<p>The installation went easily for both ruby gems and ruby, but I decided to take a &#8217;short cut&#8217; and copy all my gems from /Library/Ruby/Gems into my /usr/local/lib directory which started raising all kinds of errors &#8212; this one, in particular was obnoxious.</p>
<p><code>[BUG] cross-thread violation on rb_gc()</code></p>
<p>Luckily, all that means is that I copied over gems which were compiled against the standard OSX ruby version and not the new one. This was a little script I wrote which will show you which gems need to be re-compiled. Just <tt>cd</tt> over to your /usr/local/lib/ruby/gems/1.8/gems directory and run:</p>
<p><code><span>gems $></span>ls -1 **/**/*.bundle|ruby -pe '$_.gsub! /\-.*/, ""'|uniq</code></p>
<p>to get a list, or pipe that into <code><span>$></span> sudo gem install</code> and that should clear up those gc issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ubrio.us/nix/osx-rubygems-and-cross-thread-violations-in-rb_gc/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>History Meme</title>
		<link>http://blog.ubrio.us/code/history-meme/</link>
		<comments>http://blog.ubrio.us/code/history-meme/#comments</comments>
		<pubDate>Tue, 13 May 2008 00:40:20 +0000</pubDate>
		<dc:creator>Rob Hurring</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Nix]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bored]]></category>

		<guid isPermaLink="false">http://blog.ubrio.us/?p=97</guid>
		<description><![CDATA[Took the idea from Dive Into Mark because I&#8217;m bored.   
If you&#8217;re curious to see which commands you use the most just run:
$>history &#124; awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' &#124; sort -rn &#124; head

# local server
133 l
70 cd
47 svn
38 ..
29 e
26 mv
20 ll
10 rm
10 cp
8 ror

# remote server
123 l
74 cd
35 [...]]]></description>
			<content:encoded><![CDATA[<p>Took the idea from <a href='http://diveintomark.org/archives/2008/04/15/history-meme' onclick="pageTracker._trackPageview('/outgoing/diveintomark.org/archives/2008/04/15/history-meme?referer=');">Dive Into Mark</a> because I&#8217;m bored. <img src='http://blog.ubrio.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>If you&#8217;re curious to see which commands you use the most just run:</p>
<p><code><span>$></span>history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head</code></p>
<pre>
# local server
133 l
70 cd
47 svn
38 ..
29 e
26 mv
20 ll
10 rm
10 cp
8 ror

# remote server
123 l
74 cd
35 svn
31 touch
26 ..
23 exit
23 cat
20 ll
18 rm
16 rake
</pre>
<h4>A few notes</h4>
<p>here are those goofy aliases that you see:</p>
<pre>
alias ll='ls -lah'
alias la='ls -a'
alias l='ls -lh'
alias ..='cd ..'
alias ~='cd ~'
alias e='mate '

alias ss='./script/server'
alias console='./script/console'
alias migration='./script/migration'

alias ror='/var/rubydev'
alias www='/var/www'
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.ubrio.us/code/history-meme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Best Bash Prompt</title>
		<link>http://blog.ubrio.us/nix/best-bash-prompt/</link>
		<comments>http://blog.ubrio.us/nix/best-bash-prompt/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 05:25:20 +0000</pubDate>
		<dc:creator>Rob Hurring</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Nix]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[prompt]]></category>
		<category><![CDATA[ps1]]></category>

		<guid isPermaLink="false">http://blog.ubrio.us/osx/bash-prompt-madness/</guid>
		<description><![CDATA[Okay &#8212; so after that last post I decided it was time for a change. I&#8217;ve had the same bash prompt for years and was starting to get tired of it. Over the past 30 or so minutes I&#8217;ve been hating life learning way more than I wanted to about PS1, colors and embedded IF [...]]]></description>
			<content:encoded><![CDATA[<p>Okay &#8212; so after that last post I decided it was time for a change. I&#8217;ve had the same bash prompt for years and was starting to get tired of it. Over the past 30 or so minutes I&#8217;ve been <del>hating life</del> learning way more than I wanted to about PS1, colors and embedded IF statements.</p>
<p>And yes, this needs it own post simply for the fact that this is an insane prompt. Heres what it is/can do:</p>
<ol>
<li>Automatically shortens itself if the path is longer than 18 charachters<br/><small>This is what I&#8217;ve always wanted since I usually name my folders after the website URL &#8212; and I <em>HATE</em> 2 line prompts.</small></li>
<li>Changes to red if the last command didn&#8217;t have a return code of 0</li>
<li>Includes your bash history # for easy <a href="http://linux.deadgod.net/2007/01/01/Special_Bash_Variables_I" onclick="pageTracker._trackPageview('/outgoing/linux.deadgod.net/2007/01/01/Special_Bash_Variables_I?referer=');">history command repeating</a></li>
<li>Is pretty neat and trim</li>
</ol>
<h5>Why is this rad?</h5>
<div class='wp-caption alignleft'>
<img src="http://file.ubrio.us/misc/best_bash_prompt_ever.png" /></p>
<p class='wp-caption-text'>Prompt Madness!</p>
</div>
<p>I&#8217;ll let this image explain what it does and how it looks&#8230;</p>
<p><br clear='left' /></p>
<p>I&#8217;m tossing up a text file here -> <a href="http://file.ubrio.us/misc/best_bash_prompt_ever.txt" onclick="pageTracker._trackPageview('/outgoing/file.ubrio.us/misc/best_bash_prompt_ever.txt?referer=');">best_bash_prompt_ever.txt</a> &#8212; since the escaping will probably be messed up.</p>
<pre>
export PROMPT_COMMAND='PS1="\[\033[0;33m\][\!]\`if [[ \$? = "0" ]]; then echo "\\[\\033[32m\\]"; else echo "\\[\\033[31m\\]"; fi\`[\u.\h: \`if [[ `pwd|wc -c|tr -d " "` > 18 ]]; then echo "\\W"; else echo "\\w"; fi\`]\$\[\033[0m\] "; echo -ne "\033]0;`hostname -s`:`pwd`\007"'
</pre>
<div class='help'>The second half (from &#8220;echo -ne&#8230;&#8221; on) is for the Terminal&#8217;s title.</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ubrio.us/nix/best-bash-prompt/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Prepend files in OS X using the Command Line</title>
		<link>http://blog.ubrio.us/code/prepend-files-in-os-x-using-the-command-line/</link>
		<comments>http://blog.ubrio.us/code/prepend-files-in-os-x-using-the-command-line/#comments</comments>
		<pubDate>Mon, 12 Nov 2007 05:16:46 +0000</pubDate>
		<dc:creator>Rob Hurring</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Nix]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://blog.ubrio.us/osx/prepend-files-in-os-x-using-the-command-line/</guid>
		<description><![CDATA[This is a neat little &#8220;trick&#8221; to prepend something simple to the beginning of a file. Linux is funny in the way that you can easily append to a file by using echo "append me to the file" >> FILE but theres no real simple way to prepend. Most snippets I&#8217;ve seen use a tmp [...]]]></description>
			<content:encoded><![CDATA[<p>This is a neat little &#8220;trick&#8221; to prepend something simple to the beginning of a file. Linux is funny in the way that you can easily append to a file by using <code>echo "append me to the file" >> FILE</code> but theres no real simple way to prepend. Most snippets I&#8217;ve seen use a tmp file but thats silly when OS X gives you some amazing programs. </p>
<p>Using <code>pbcopy</code> and <code>pbpaste</code> can save your life sometimes and are probably one programs I miss the most when using Linux. Anyway, heres just a simple &#8220;1 liner&#8221; for prepending.</p>
<p><code class='prettyprint'>cat FILE | pbcopy &#038;&#038; echo "Prepend Text" > FILE &#038;&#038; pbpaste >> FILE</code></p>
<p>Pretty simple, but it can be useful at times &#8212; like when you have a script that would be better off with a shebang line than being run by hand and you&#8217;re too lazy to open an editor.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ubrio.us/code/prepend-files-in-os-x-using-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making find and tar play nicely</title>
		<link>http://blog.ubrio.us/nix/making-find-and-tar-play-nicely/</link>
		<comments>http://blog.ubrio.us/nix/making-find-and-tar-play-nicely/#comments</comments>
		<pubDate>Thu, 27 Sep 2007 21:45:35 +0000</pubDate>
		<dc:creator>Rob Hurring</dc:creator>
				<category><![CDATA[Because I'll Forget]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Nix]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[tar]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://blog.ubrio.us/because-ill-forget/because-ill-forget-1023/</guid>
		<description><![CDATA[Because I&#8217;ll forget #1023
Problem
Use Linux&#8217;s &#8220;find&#8221; command to hunt recursively through the current directory tree and find all matching files. While this is simple enough, I&#8217;m an idiot and tend to delete important files when drinking working too much &#8212; which we all know sucks. It would be nice to have it take all found [...]]]></description>
			<content:encoded><![CDATA[<h3>Because I&#8217;ll forget #1023</h3>
<p><strong>Problem</strong></p>
<p>Use Linux&#8217;s &#8220;find&#8221; command to hunt recursively through the current directory tree and find all matching files. While this is simple enough, I&#8217;m an idiot and tend to delete important files when <del>drinking</del> working too much &#8212; which we all know sucks. It would be nice to have it take all found files, tar them up and move it to the trash.</p>
<p><strong>Solution</strong></p>
<p>The evil, but oh-so-useful <code>xargs</code> command is your saving grace. While I hate using xargs its damn useful. If you take the output of find and pipe it into <code>tar</code> then pipe THAT into <code>rm</code> you get the job done. </p>
<p><strong>Example</strong></p>
<p>This is just a simple hack I&#8217;ve put together which seems to work and is relatively simple. (done as a bash function)</p>
<pre class='prettyprint'>
frm(){
	find . -name "$1" | xargs tar rvf "$1.tar" | xargs rm -rfv &#038;&#038; mv $1.tar ~/.trash
}
</pre>
<p>I just needed this because I had to wipe all <code>./.svn</code> directories so i just typed <code>frm .svn</code> and it created a .svn.tar and moved that to ~/.trash. Good stuff <img src='http://blog.ubrio.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ubrio.us/nix/making-find-and-tar-play-nicely/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

