matthew as a q.

競技プログラミングメイン

git hook

git hookで,コマンド等をフックにして,いろいろできるらしい.

参考事例:
コミットしたら鳥海が抜錨するgit hookをつくった #艦これAdventCalendar 5日目 - blogですかい

$ git init
$ alias vim=emacs
$ vim .git/hooks/post-commit

  • -

#!/bin/bash
dir='/path/to/chokai/voices/dir/'
files=(`/bin/ls $dir`)
afplay $dir${files[($RANDOM % ${#files[@]})]} &

  • -

$ chmod +x .git/hooks/post-commit

こんな感じにするらしい.
voiceを置いてるところを指定して,そのディレクトリの中身をlsした結果をfilesに保存(files=(`/bin/ls $dir`)).そのディレクトリのファイルの中から,ランダムに1つ選んで(具体的には,乱数をfiles数で割った余りで指定)(($RANDOM % ${#files[@]}))再生(afplay).

知らなかったので,メモ.