To accompany you when using cherry-pick. If you can use git python, it may be better to use it obediently. It doesn't make much sense to write in Python in the first place ...
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
(Addition) Version using sys.stdin without using subprocess module. This is still a little easier to write.
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
Recommended Posts