Home > Resources, Tutorials > OS X Git Prompt

OS X Git Prompt

November 15th, 2009 shaun Leave a comment Go to comments

I’m currently using a modified version of git-prompt that looks something like this:

Git-prompt

If you want to try it out, you can download this zip-ball:

git-prompt.zip

Unpack that into your User folder, and add this to your bash .profile:

# Git Prompt - Modified from: http://volnitsky.com/project/git-prompt/
[[ $- == *i* ]] && . ~/git-prompt/git-prompt.sh

Tip: You can open your .profile from your terminal like so:

open ~/.profile

Note: You will need to start a new shell session after editing that file in order to see the changes.

I use Nano as my default bash text editor. If you want that, add this to your .profile:

# Use the nano text editor
export EDITOR="nano"

And for the Terminal.app style:

Terminal-prefs

Power-User-Pro.terminal.zip

The shell commands (copy-paste):

mkdir Test
cd Test/
git init
touch somefile
git add somefile
git commit -m "commit message"
echo "hi" > somefile
git add somefile
git commit -m "second commit"
git checkout -b temp
echo "hello" > somefile
git add .
git commit -m "3rd commit"
Categories: Resources, Tutorials Tags: , , , ,
  • Awesome. This rocks.
  • Hmm.. I'm sorry to hear that you had trouble with it. I'm pretty new to all this myself. My Terminal is still set to /usr/bin/login. It might have something to do with how git is installed: port vs installer vs manually compiling it. Also, I should definitely have mentioned that you need to start a new Terminal session after editing the .profile!
  • Hi Shaun,

    Thanks for this. I had quite a few problems getting it to work for me, which was frustrating. In the end I went into my Terminal/preferences/startup and switched the "Shell opens with" from /usr/bin/login to /bin/bash. Then I saved my .profile file (with modifications as above) to .bash_profile. Finally, on restarting my terminal, it worked.

    I've never mucked around with bash so I was pretty much in the dark, and getting it to work is dumb luck.

    In any event, thank you for introducing me to the GIT Prompt project; this is going to come in very handy!
blog comments powered by Disqus