Jazzy Coding

The Art of Structured Improvisation. By Carsten Nielsen

Tag Archives: bash

git statistics: bash-one-liners

Are you interested in the statistics of your project? Who has done how many commits? On which week of the day or hour of day?
Well, here’s some food for you. Simple one-liners for the shell:

The committers-ranking by number of commits.

$> git shortlog  -ns

The commits of a project by weekday.

$> for i in Mon Tue Wed Thu Fri Sat Sun; do echo $( echo " $i: "; git shortlog  -n --format='%ad %s'| grep "$i " | wc -l); done

The commits of a project by weekday since a defined date. Interesting to see the difference ex. after a project has been released as open-source or the project-team has changed. You can change the option ‘since’ to ‘until’ if you want to count the commits before a defined date.

$> for i in Mon Tue Wed Thu Fri Sat Sun; do echo $( echo " $i: "; git shortlog  -n --format='%ad %s' --since='2011-06-31'| grep "$i " | wc -l); done

The commits of a project by hour of day. (Updated after the hint from Patrik. Thanks!)

$> for i in `seq -w 0 23`; do echo $( echo " $i:"; git shortlog  -n --format='%ad %s' | grep " $i:" | wc -l); done

The commits of a project by hour of day before a defined date. Even here you can change the option ‘until’ to ‘since’ if needed.

$> for i in `seq -w 0 23`; do echo $( echo " $i:"; git shortlog  -n --format='%ad %s' --until='2011-06-31' | grep " $i:" | wc -l); done
Advertisements

gnome-shell: reload after freeze

Ok, it happened again.

In a nice productive coding session my gnome-shell unexpectedly freezed. The gnome-session got completely unresponsive… or nearly – I was able to switch to another terminal-session.

Using the top command I was able to see that really the gnome-shell-session was eating memory and cpu-time like hell. But how can I send a gnome-shell-reload-command to another terminal-session? No results after a research on the lazy-web… I had to hard-reset my system reset the gdm-windowmanager – nearly loosing all my unsaved code. (Mainly avoided, lucky as I am with a git commit of the cached files in the coding folder – but that’s another story…)

Hmm – what to do then? I need a method to reset the gnome-shell from another session…

I can’t send any commands to another tty (as far as I know). But hey! The sessions are using the same file system!

As a workaround I wrote a small script that runs under the actual gnome-shell-session, checks the existence of a file every 10 seconds and if this file don’t exist simply reloads the gnome-shell-session.

~/.config/gnome-shell-restarter/restarter.sh

#!/bin/bash cd ~/.config/gnome-shell-restarter/

while true ;do
if [ -f delete-to-reload-gnome-shell ] ;then
sleep 10;
else
touch delete-to-reload-gnome-shell;
gnome-shell --replace
fi
done;

As you can see I’ve put the script in the .config folder. I’ve added it to my gnome-autostart by using the “gnome-session-properties” gui-tool.

In case my gnome-shell freezes again, I simply switch to another session with Ctrl-Alt-F1 and delete the “delete-to-reload-gnome-shell” file. Voilá! the gnome-session restarts!

If you have a better solution for this or maybe any hints on gnome-shell, feel free to comment!