Brain Phrye

code cooking diy fiction personal photos politics reviews tools


My Year In Vim

tl;dr my year in vim

Gource is a neat tool for visualising the history of a of a software project. In a way it’s kind of a fun combination of this scene Jurassic Park and version control.

Reading up on it I learned it could also visualise multiple repositories so I decided it would be kind of fun to do just that. I use vcsh to manage my home directory, pass to manage passwords, Hugo for my website and slack for managing my personal servers.

Note that I use git subtree to pull in some third-party tools in my slack repo. So there will be some “guests” committing besides me.

To do all this I used a script. It follows here below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash

vcsh pull
pass git pull
src_repos=(slack phrye.com)
for r in "${src_repos[@]}"; do
  ( cd $HOME/src/$r && git pull )
done

gource_args=()
if [[ -n "$1" ]]; then
  first=$(perl -e "use Time::Local; print(timelocal(0,0,0,1,0,$1))")
  nextyear=$(($1 + 1))
  gource_args+=(--start-date "$1-01-01 00:00:00")
  gource_args+=(--stop-date "$nextyear-01-01 00:00:00")
else
  first=$(pass git log --pretty='format:%ct' --reverse | head -1)
  for r in $(vcsh list); do
    oldest=$(vcsh "$r" log --pretty='format:%ct' --reverse | head -1)
    if [[ $oldest < $first ]]; then
      first=$oldest
    fi
  done
  first=$((first - 1))
fi

(
  for r in $(vcsh list); do
    echo "$first|Kevin Lyda|A|/$r"
    vcsh "$r" log --pretty=format:"%ct|%aN|" --reverse --raw \
      | awk '/^[0-9]/ {p=$0}
             /^:/ {printf("%s%s|'"/$r/"'", p, $5);
                   for (i=6;i<=NF;i++){
                     printf("%s%s", i>6 ? "|" : "", $i)
                   } printf("\n")}'
  done;
  echo "$first|Kevin Lyda|A|/pass"
  pass git log --pretty=format:"%ct|%aN|" --reverse --raw \
    | awk '/^[0-9]/ {p=$0}
           /^:/ {printf("%s%s|/pass/", p, $5);
                 for (i=6;i<=NF;i++){
                   printf("%s%s", i>6 ? "|" : "", $i)
                 } printf("\n")}'
  for r in "${src_repos[@]}"; do
    echo "$first|Kevin Lyda|A|/$r"
    (
      cd $HOME/src/$r \
        && git log --pretty=format:"%ct|%aN|" --reverse --raw \
          | awk '/^[0-9]/ {p=$0}
                 /^:/ {printf("%s%s|'"/$r/"'", p, $5);
                       for (i=6;i<=NF;i++){
                         printf("%s%s", i>6 ? "|" : "", $i)
                       } printf("\n")}'
    )
  done;
) \
  | sort -n \
  | gource "${gource_args[@]}" \
    --hide-root --user-image-dir images --logo images/logo.png \
    --title "My year in vim" \
    --file-extensions --key --filename-time 2 -t 90 --stop-at-end \
    --dir-name-depth 2 -a 0.2 -s 0.2 -1280x720 -o - --log-format custom - \
  | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - \
    -vcodec libx264 -probesize 10M \
    -preset slow -pix_fmt yuv420p -crf 18 -threads 0 -b_strategy 2 \
    -aspect 16:9 ~/end-of-year-gource.mp4

There are some hard coded bits I don’t like. One is that I force gource to stop after 90 seconds (the -t 90 bit) and had to do that because otherwise it just hung around w/o ending the video. I’ll have to reset that next year since last year I likely did less commits due to all the discombobulation at home due to construction.