<?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>nothing2fancy &#187; Development</title>
	<atom:link href="http://nothing2fancy.com/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://nothing2fancy.com</link>
	<description>pew-pew</description>
	<lastBuildDate>Sat, 19 Jun 2010 16:27:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Bash Autocompletion for Git</title>
		<link>http://nothing2fancy.com/2010/06/19/bash-autocompletion-for-git/</link>
		<comments>http://nothing2fancy.com/2010/06/19/bash-autocompletion-for-git/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 16:23:57 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[git autocompletion bash]]></category>

		<guid isPermaLink="false">http://nothing2fancy.com/?p=363</guid>
		<description><![CDATA[The default installation of Git on OS X doesn&#8217;t include support for autocompletion. I know it&#8217;s possible, because whatever package I used to install Git on my Windows work computer has it, but I&#8217;ve never taken the time to figure it out. Well, here&#8217;s how it works. Note that these instructions were about 10x longer, [...]]]></description>
			<content:encoded><![CDATA[<p>The default installation of Git on OS X doesn&#8217;t include support for autocompletion. I know it&#8217;s possible, because whatever package I used to install Git on my Windows work computer has it, but I&#8217;ve never taken the time to figure it out. Well, here&#8217;s how it works. Note that these instructions were about 10x longer, until I decided to read the contents of the bash-completion.bash script&#8230; the installation is a lot easier than I was making it.</p>

<p>First, you need to copy the bash-completion script somewhere appropriate.</p>

<p><pre>
cd /usr/local/git/contrib/completion/
cp git-completion.bash ~/.git-completion.sh
</pre></p>

<p>Now add the following line to your ~/.bash_profile</p>

<p><pre>
source ~/.git-completion.sh
</pre></p>

<p>Next time you login, autocompletion in Git should work just fine. If you want to take it one step further, here&#8217;s how you add the current branch to your command line. The bash-completion script tells you to change your <code>PS1</code> to the following.</p>

<p><pre>
PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
</pre></p>

<p>Which is cool, but I already had my <code>PS1</code> set up, complete with colors and shit. Here&#8217;s what I ended up doing.</p>

<p><pre>
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWDIRTYSTATE
export GIT_PS1_SHOWSTASHSTATE
export GIT_PS1_SHOWUNTRACKEDFILES</p>

<p>PS1='&#91;\e[1;32m&#93;$(__git_ps1 " (%s)")&#91;\e[m&#93;'
PS1="&#91;\e[1;36m&#93;\h:\W&#91;\e[m&#93;$PS1&#91;\e[1;36m&#93;> &#91;\e[m&#93;"
export PS1
</pre></p>

<p>What a mess! I&#8217;m never going to be able to remember what I did here unless I write it down here.</p>

<p>First off, the <code>GIT_PS1_</code> variables add an indicator to your command line letting you know that you&#8217;re in a dirty working directory, you have something stashed or there are untracked files. Handy.</p>

<p>Second, anything between <code>&#91;\e[1;32m&#93;</code> and <code>&#91;\e[m&#93;</code> is given a color. You can read more about it <a href="http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/">here</a>.</p>

<p>Finally, the function <code>$(__git_ps1 " (%s)")</code> will replace <code>%s</code> with the current branch (plus a flag if you&#8217;ve set those variables I described earlier) if you are currently in a directory under Git source control.</p>

<p>The final result:</p>

<p><img src="http://nothing2fancy.com/images/forum_images/Terminal_%E2%80%94_bash_%E2%80%94_80%C3%9748-20100619-121337.png" alt="Terminal%20%E2%80%94%20bash%20%E2%80%94%2080%C3%9748"/></p>

<p>I&#8217;ll be updated my <a href="http://nothing2fancy.com/2010/02/01/my-bash_profile/">recent post on my <code>.bash_profile</code></a> to reflect these changes.</p>
]]></content:encoded>
			<wfw:commentRss>http://nothing2fancy.com/2010/06/19/bash-autocompletion-for-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My .bash_profile</title>
		<link>http://nothing2fancy.com/2010/02/01/my-bash_profile/</link>
		<comments>http://nothing2fancy.com/2010/02/01/my-bash_profile/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 11:20:03 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[profile]]></category>

		<guid isPermaLink="false">http://nothing2fancy.com/?p=348</guid>
		<description><![CDATA[In case anyone is interested. The meat of it is a bunch of two-letter aliases for common Git commands. My favorite part, though, is the shortcut to SSH into the iMac. My iMac has an equivalent alias to SSH into my MacBook. Makes it super easy to login and push whatever I was working on [...]]]></description>
			<content:encoded><![CDATA[<p>In case anyone is interested. The meat of it is a bunch of two-letter aliases for common Git commands. My favorite part, though, is the shortcut to SSH into the iMac. My iMac has an equivalent alias to SSH into my MacBook. Makes it super easy to login and push whatever I was working on back to the server, if I&#8217;d forgotten to after switching computers.</p>

<p>Oh, and this isn&#8217;t in my profile, but just learned this trick last week and which I had known about it years ago. In OS X, &#8216;open ./&#8217; opens the current directory in Finder.</p>

<p><pre></p>

<h1>!/bin/bash</h1>

<h1>This is the preferred file for running init commands</h1>

<h1>This file will be run on any login</h1>

<p>echo
echo "######################################"
echo "#                                    #"
echo "#     Welcome to Jim's Macbook       #"
echo "#                                    #"
echo "######################################"
echo</p>

<h1>setting up bash completion</h1>

<p>source ~/.git-completion.sh
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWDIRTYSTATE
export GIT_PS1_SHOWSTASHSTATE
export GIT_PS1_SHOWUNTRACKEDFILES</p>

<p>PATH=$PATH:/Users/jkubicek/bin
export PATH</p>

<p>PS1='&#91;\e[1;32m&#93;$(__git_ps1 " (%s)")&#91;\e[m&#93;'
PS1="&#91;\e[1;36m&#93;\h:\W&#91;\e[m&#93;$PS1&#91;\e[1;36m&#93;> &#91;\e[m&#93;"
export PS1</p>

<p>alias ls='ls -G'
alias imac='ssh jimk@imac.local'
alias gc='git commit -m'
alias ga='git add .'
alias gs='git status'
alias grso='git remote show origin'
alias gl='git log --oneline --graph'</p>

<p></pre></p>

<p>Updated: I added a bunch of stuff related to git autocomplete, in light of my <a href="http://nothing2fancy.com/2010/06/19/bash-autocompletion-for-git/">recent post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nothing2fancy.com/2010/02/01/my-bash_profile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
