Changing The Language Of A Specific Program
The MacPorts update I ran a couple of weeks ago caused my git to upgrade to 1.7.10.2 - and switch from English to German. The workaround to make git speak English again while not chaning the locale of the entire system is rather trivial. But since I'm terrible at remembering that sort of stuff, documenting it might help with the next update… ☺
Why Do I Need An English GIT?
Simple. I have a bunch of tools parsing a git call's output to integrate git into other environments. The most obvious of such tools would be the GIT integration for TextMate. The more fiddely thing I did is customize my prompt a bit:
Just copy the following into your ~/.profile
and try it out yourself:
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1="\[\033[01;34m\]\W \[\033[1;31m\]\$(parse_git_branch)\[\033[01;34m\]\$\[\033[00m\] "
Changing The Locale
if you were to export LC_ALL="en_US.UTF-8"
, you'd switch your system completely to english. This is not what I want though. Other programs should still use my German locale (sorting stuff…).
With which git
you find out where your git binary is located - cd
to that directory. Rename the git binary: mv git git_real
. Now create a new file and give it executable permissions: touch git; chmod ugo+x git
. Copy the following into the newly created file:
LC_ALL="en_US.UTF-8" exec /opt/local/bin/git_real "$@"
et voila, your git is quacking English again. (at least up to its next update…)
The author does not allow comments to this entry
Comments
Display comments as Linear | Threaded
Christian Kruse on :
You're welcome ;-)
Rodney Rehm on :
Thanks for being my interactive bash manual, once again :)