-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.xml
53 lines (42 loc) · 2.96 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[Vincent Cardillo]]></title>
<link href="http://vcardillo.github.io/atom.xml" rel="self"/>
<link href="http://vcardillo.github.io/"/>
<updated>2015-01-01T21:19:28-08:00</updated>
<id>http://vcardillo.github.io/</id>
<author>
<name><![CDATA[Vincent Cardillo]]></name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[Putting the Git Branch Name on the Command Prompt]]></title>
<link href="http://vcardillo.github.io/blog/2014/12/11/putting-the-git-branch-name-on-the-command-prompt/"/>
<updated>2014-12-11T20:32:00-08:00</updated>
<id>http://vcardillo.github.io/blog/2014/12/11/putting-the-git-branch-name-on-the-command-prompt</id>
<content type="html"><![CDATA[<p>Sometimes it’s handy to always see which branch of the repository we’re working in. We can display this as part of the terminal command prompt by adding a few things to our local <code>.bashrc</code> file.</p>
<figure class='code'><figcaption><span>~/.bashrc</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="k">function</span> parse_git_branch <span class="o">{</span>
</span><span class='line'> git branch 2> /dev/null <span class="p">|</span> sed -e <span class="s1">'/^[^*]/d'</span> -e <span class="s1">'s/* \(.*\)/ (\1)/'</span>
</span><span class='line'><span class="o">}</span>
</span><span class='line'>
</span><span class='line'><span class="c"># This will display the current folder's full path.</span>
</span><span class='line'><span class="c"># If you want only the folder name, replace \w with \W</span>
</span><span class='line'><span class="nb">export </span><span class="nv">PS1</span><span class="o">=</span><span class="s2">"\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\[\033[36m\]\$(parse_git_branch)\[\033[0m\]\$ "</span>
</span><span class='line'>
</span></code></pre></td></tr></table></div></figure>
<p>And now our command prompt looks like this:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>you@host:~/Project/folder <span class="o">(</span>master<span class="o">)</span><span class="nv">$ </span>
</span></code></pre></td></tr></table></div></figure>
<p>The branch name will always be displayed in parenthesis for us.</p>
]]></content>
</entry>
</feed>