I was just talking to a coworker about a couple of things I did a while back to make working with git a little less painful, so I figured I might as well share them with everyone.

The first is a post-checkout script, to regenerate cscope information any time a new branch is checked out. Just put this in $your_git_tree/.git/hooks to use it. If anybody knows how to make this global instead of per-tree, or how to do the same thing for every other git operation that might add/remove source files in your tree, please let me know.

The second is a window-title script which will check to see if you’re in a git tree and, if so, add the current branch to the current directory. For example, my PROMPT_COMMAND looks like this.

‘printf “\033]0;%s@%s:%s\007″ “${USER}” “${HOSTNAME%%.*}” “$(pwd_with_branch)”‘

As a result, one of my window titles now looks like this.

jdarcy@jdarcy-dt:~/projects/glusterfs_github (hsrepl)

Here, “hsrepl” is the name of the branch I’m currently working on. You could just as easily use this to set your command prompt instead of your window title if you were so inclined.

Enjoy, and patches welcome. ;)