<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc=" http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>briancarper.net (λ) (Tag: Git)</title><link>http://briancarper.net/tag/225/git</link><description>Some guy's blog about programming and Linux and cows.</description><item><title>Git info in your ZSH Prompt</title><link>http://briancarper.net/blog/570/git-info-in-your-zsh-prompt</link><guid>http://briancarper.net/blog/570/git-info-in-your-zsh-prompt</guid><pubDate>Fri, 10 Sep 2010 13:31:37 -0700</pubDate><description>&lt;p&gt;Recently I discovered &lt;a href=&quot;http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#SEC273&quot;&gt;vcs_info&lt;/a&gt; recently.  This nicely replaces the horrible hack I was using previously to show current Git status.  vcs_info works with VCSes besides Git, and it handles some of the magic and keeps your &lt;code&gt;.zshrc&lt;/code&gt; clean, so those are nice benefits.&lt;/p&gt;

&lt;p&gt;I used some Unicode to display colored circles.  Green if there are staged changes, yellow if there are unstaged changes, and red if there are new untracked-yet-unignored files.  Below is a picture.&lt;/p&gt;

&lt;p&gt;I like this because I'm constantly forgetting to &lt;code&gt;git add&lt;/code&gt; newly-created files.  Then I have to add them and amend my commit, and so on.  I like a prompt that reminds me that new files showed up that need to be added or ignored.&lt;/p&gt;

&lt;p&gt;Code:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;brush: bash&quot;&gt;autoload -Uz vcs_info

zstyle ':vcs_info:*' stagedstr '%F{28}●'
zstyle ':vcs_info:*' unstagedstr '%F{11}●'
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{11}%r'
zstyle ':vcs_info:*' enable git svn
precmd () {
    if [[ -z $(git ls-files --other --exclude-standard 2&amp;gt; /dev/null) ]] {
        zstyle ':vcs_info:*' formats ' [%F{green}%b%c%u%F{blue}]'
    } else {
        zstyle ':vcs_info:*' formats ' [%F{green}%b%c%u%F{red}●%F{blue}]'
    }

    vcs_info
}

setopt prompt_subst
PROMPT='%F{blue}%n@%m %c${vcs_info_msg_0_}%F{blue} %(?/%F{blue}/%F{red})%% %{$reset_color%}'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Picture:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/random/zsh-git.png&quot; alt=&quot;ZSH and Git&quot; title=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h1&gt;Limitations&lt;/h1&gt;

&lt;p&gt;As you can see in the screenshot, when you have a brand new Git repo (no commits yet), vcs_info fails to show you that there are files staged.  It works OK after you have at least one commit though.&lt;/p&gt;

&lt;p&gt;vcs_info doesn't (yet?) handle showing untracked files.  So I hacked a function to support it.&lt;/p&gt;

&lt;p&gt;Finding a good Unicode symbol that displays nicely in monospace font was annoying.  If I ever change fonts, I'll likely have to pick a new symbol.  It also doesn't display too well in a real tty.  Or over SSH when using Putty.  So I may have to scrap the stoplights and use plus-signs or something.  Sigh.&lt;/p&gt;</description></item><item><title>Git tutorial</title><link>http://briancarper.net/blog/git-tutorial</link><guid>http://briancarper.net/blog/git-tutorial</guid><pubDate>Sat, 09 May 2009 13:55:59 -0700</pubDate><description>&lt;p&gt;Finally I found a good &lt;a href=&quot;http://book.git-scm.com/index.html&quot;&gt;Git tutorial&lt;/a&gt; that starts from the absolute basics and goes steadily through more advanced things.  I highly recommend it.&lt;/p&gt;</description></item><item><title>A Sad, Dark Day</title><link>http://briancarper.net/blog/a-sad-dark-day</link><guid>http://briancarper.net/blog/a-sad-dark-day</guid><pubDate>Mon, 13 Apr 2009 01:27:12 -0700</pubDate><description>&lt;p&gt;Today was a terrible day.  I found myself subconsciously trying to use Emacs keystrokes in Vim.  I feel dirty.  I took a bath but it won't come clean.  : (&lt;/p&gt;

&lt;p&gt;It just goes to show that &lt;a href=&quot;/blog/lisp-syntax-doesnt-suck&quot;&gt;you can get used to anything&lt;/a&gt; if you do it often enough.  Emacs still drives me up the wall but maybe I've achieved a critical mass of enough custom keybindings to let me tolerate it.&lt;/p&gt;

&lt;p&gt;Aside from &lt;code&gt;paredit&lt;/code&gt;, which has no equal even in Vim, Emacs does have some vaguely non-sucky features.  &lt;code&gt;hi-lock&lt;/code&gt; is pretty nice (Vim has an equivalent of course).  Once I learned a few of the shortcuts for &lt;a href=&quot;http://github.com/tsgates/git-emacs/tree/master&quot;&gt;git-emacs&lt;/a&gt; I actually found myself using Git much more effectively.  Having to drop into a shell to type Git commands is just enough of a disruption to prevent me from doing it often enough.  I never got the hang of any version control library in Vim.&lt;/p&gt;

&lt;p&gt;I'm almost even getting used to the Emacs buffer model.  I find myself &lt;code&gt;C-x b&lt;/code&gt;ing and flipping back and forth between buffers by name, rather than my Vim practice of opening buffers in certain carefully-placed windows and leaving them there.&lt;/p&gt;

&lt;p&gt;On the subject of typing, I broke down finally and ordered a &lt;a href=&quot;http://pckeyboards.stores.yahoo.net/customizer.html&quot;&gt;Unicomp Customizer 104 keyboard&lt;/a&gt;.  I've heard too many hackers say that the old IBM clicky keyboards are good for typing.  It should arrive Tuesday, and I'm a lot more excited than anyone should be over a keyboard.  &lt;/p&gt;

&lt;p&gt;Expect a keyboard review.  Try to contain your excitement until then.  I know it'll be hard.&lt;/p&gt;</description></item></channel></rss>

