Bash Autocompletion for Git

The default installation of Git on OS X doesn’t include support for autocompletion. I know it’s possible, because whatever package I used to install Git on my Windows work computer has it, but I’ve never taken the time to figure it out. Well, here’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… the installation is a lot easier than I was making it.

First, you need to copy the bash-completion script somewhere appropriate.

cd /usr/local/git/contrib/completion/
cp git-completion.bash ~/.git-completion.sh

Now add the following line to your ~/.bash_profile

source ~/.git-completion.sh

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

PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '

Which is cool, but I already had my PS1 set up, complete with colors and shit. Here’s what I ended up doing.

GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWDIRTYSTATE
export GIT_PS1_SHOWSTASHSTATE
export GIT_PS1_SHOWUNTRACKEDFILES

PS1='[\e[1;32m]$(__git_ps1 " (%s)")[\e[m]' PS1="[\e[1;36m]\h:\W[\e[m]$PS1[\e[1;36m]> [\e[m]" export PS1

What a mess! I’m never going to be able to remember what I did here unless I write it down here.

First off, the GIT_PS1_ variables add an indicator to your command line letting you know that you’re in a dirty working directory, you have something stashed or there are untracked files. Handy.

Second, anything between [\e[1;32m] and [\e[m] is given a color. You can read more about it here.

Finally, the function $(__git_ps1 " (%s)") will replace %s with the current branch (plus a flag if you’ve set those variables I described earlier) if you are currently in a directory under Git source control.

The final result:

Terminal%20%E2%80%94%20bash%20%E2%80%94%2080%C3%9748

I’ll be updated my recent post on my .bash_profile to reflect these changes.

Quickr is in the App Store

Exciting news! My first iPhone app was approved for sale on the iTunes app store.

Go check it out, you can read more about it at basilapps.com or on the iTunes store.

BasilApps.com

Don’t worry. I’ll still remember all the old friends when I’m sipping Crystal on my yacht.

Do you have way too many flagged items in Google Reader?

Do you use NetNewsWire?

If so, maybe you can use this script. It finds all the items you’ve flagged that are older than 6 months old and unflags them. Seriously dude… you aren’t going to ever go back and read that shit.

set dateLimit to (current date) - (180 * days)
tell application "NetNewsWire"
    set flaggedItemList to item 1 of (subscriptions where display name is "Flagged Items")
    --get date published of headlines of flaggedItemList
    set oldFlaggedArticles to (headlines of flaggedItemList) where date published < dateLimit
    repeat with article in oldFlaggedArticles
        set isFlagged of article to no
    end repeat
    set theMessage to "Marked " & (count of oldFlaggedArticles) & " flagged items as read. They were all from before " & dateLimit & "."
    display alert "Marked as read" message theMessage
end tell

Unflag old Flagged Items.zip

I’ve got a solo exhibit

Into Darkness.png

I didn’t think I was actually going to get it, but I was selected for a solo exhibit at the Richmond Main Library.

The first month available is in November, 2010, so i’ve got the better part of a year to prepare. You can check out the images I submitted at jimkubicek.com.

My .bash_profile

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’d forgotten to after switching computers.

Oh, and this isn’t in my profile, but just learned this trick last week and which I had known about it years ago. In OS X, ‘open ./’ opens the current directory in Finder.

!/bin/bash

This is the preferred file for running init commands

This file will be run on any login

echo echo "######################################" echo "# #" echo "# Welcome to Jim's Macbook #" echo "# #" echo "######################################" echo

setting up bash completion

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

PATH=$PATH:/Users/jkubicek/bin export PATH

PS1='[\e[1;32m]$(__git_ps1 " (%s)")[\e[m]' PS1="[\e[1;36m]\h:\W[\e[m]$PS1[\e[1;36m]> [\e[m]" export PS1

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'

Updated: I added a bunch of stuff related to git autocomplete, in light of my recent post.

Headphone Review

I’ve currently got three pairs of headphones, and fortunately they are all different enough that each one serves a pretty specific purpose.

Just got a pair of Grado S60s for a 2nd generation iPod Shuffle.

Love them. Crystal clear sound, but, like other reviewers have said, almost no sound isolation. Everyone can hear your music and you can hear everyone else. Best for listening at home.

Of course, I probably wouldn’t have gotten them at all if it wasn’t a trade since I’ve also got a pair of Sennheiser 280s.

Much more isolation, but the sound isn’t as full or clear. Also, they are a little tight, so if you’ve got a huge pumpkin-head, you’ll have to stretch these bad-boys out.

Oh, and if you’ve got a new Apple product, you can’t go wrong with these:

Yeah, they let you play/pause on any iPhone and let you adjust the volume on an iPhone 3GS… but did you know you can also play/pause/volume on newer MacBooks and iMacs? Yeah… they are also super isolating and sound pretty darn good. Don’t try to use them for long conversations, though. The isolation makes talking on them kind of weird.

jimkubicek.com has been updated

I probably won’t be updating nothing2fancy.com every time I update jimkubicek.com, but I thought I’d make an exception this time.

Check it out!

I’ve got my first real portfolio hosted now, it was my submission to a solo art exhibit at the Richmond Public Library. I find out next weekend if I’ve been selected, so wish me luck. I’m not to worried about it. If I don’t make the cut, I just saved about $500 in printing and mounting… so you know, I’ve got that going for me.

“Error establishing a database connection” when installing Wordpress on OS X

This drove me nuts for a few days. I’ve been trying to set up a test environment on my desktop so that I can work through website iterations without fouling up this site. I walked through all the tutorials out there, but just could not get my Wordpress install to work.

WordPress › Error.png

Username, password, hostname were double and triple checked.

It turns out, that when I was installing MySQL on my computer (following the official instructions, which are just fine), I set up a UNIX socket. When I was setting up phpMyAdmin it explicitly asked for the socket… but Wordpress doesn’t, so it had never occurred to me to enter it.

You should enter it.

wp-config.php - Focus Group Camera Club.png

It’s for my local camera club, btw. Look for a new page some time into the new year.

Focus Group Camera Club.png

Thanks to everyone who came out Friday night

My little part of the the show was a great success. I think roughly 1/3 of the guests who visited were with me, so good job guys! I know Stephanie had a great time, too.

web (1 of 1).jpg

In other news, I was approached by the library curator. She liked my work and suggested that I submit my portfolio for a solo show. I’ve got a little over 1 month to prepare, so I’m going to get right on that.

Come see my exhibit Friday!

I’m showing three images with the Richmond Focus Camera Club tomorrow night (Friday, December 3) at the Richmond Main Library, Gelman Room. First Friday is going on that night, so I figure most of you will be out and about. The reception lasts from 7-9PM. I hope some folks can make it out to say hi to me!

Exhibit.png

Location: Richmond Main Library Gelman Room 101 East Franklin Street Richmond, VA

Time: 7-9PM

Map:

main library - Google Maps.png