cherry-pickを使う際のお供に.
gitpythonが使えるなら素直にそっちを使った方がよいかも.
そもそもPythonで書く意味はあまりない…
python -c "n = 1; import re ;from subprocess import Popen, PIPE;import sys; sys.stdout.write([commit.split(' ')[1] for commit in re.split('\n*', Popen(['git', 'log'], stdout=PIPE).communicate()[0]) if commit.startswith('commit ')][n])" | pbcopy
(追記) subprocessモジュールを使わないでsys.stdinを使用したバージョン.こっちの方がまだ少しは書きやすい.
git log | python -c "import sys; word = 'commit '; n = 0; p = lambda x: sys.stdout.write(x); l = [line.replace(word, '') for line in sys.stdin if line.startswith(word)]; p(l[n])" | pbcopy