Skip to main content


Showing posts from April, 2011

git import

I had a set of old files with the correct timestamp on, relating to separate versions of a file, ie, foo_16.c, foo_17.c, ... foo_22.c which I wanted to import into a new git repo while preserving the author history

so, this little snippet of code worked - may be useful for others

$ git init
$ git add -N foo.c
$ for i in `seq 16 22` ; do
cp -p hist/foo_$i.c foo.c;
GIT_COMMITTER_DATE="`date -R -r foo.c`" git commit \
--author "Fred Bloggs <>" \
--date="`date -R -r foo.c`" -m "Version $i" foo.c

which you can then branch and commit as normal with current changes

Yes I could probably have done GIT_AUTHOR_DATE=$GIT_COMMITTER_DATE but well, 2 calls to date wasn't that much of an overhead in this case.

anyway, for those that care, the result is up on github

Bash, PS1, PROMPT_COMMAND and other fun

I've just spent 30 mins trying to understand the flow between the various files that set a bash prompt on fedora to do the following: (assumption is here that you're in a colour xterm)

I want:
* my username to change colour depending if I still have a valid kerberos token
* the hostname of the machine I'm on to be in RED if I'm root
* displayed path to be as simple as possible
* $ if I'm a minion, # if root as mormal
* command line editing to work sensibly, no wierdisms on wrapping long lines

so - I used to have on my machine something like the following:
if [ "$PS1" != "" ] ; then
klist -s
if [ $? -eq 0 ] ; then
PS1='\[\033[32m\]\u@\h\[\033[0m\]:\w\$ '
PS1='\[\033[36m\]\u\[\033[32m\]@\h\[\033[0m\]:\w\$ '
and something similar for root.

But on my laptop (F14) I wanted it system wide, so went down the approach of customising /etc/bashrc where you find calls to

1) /etc/sysconfig/bash-…