Last active
November 6, 2022 06:30
git fortune
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# get your `fortune` from a random commit in the current git repository | |
# falling back to a helpful message | |
in_git_repo=$? | |
if ! git rev-parse --is-inside-work-tree >/dev/null 2>/dev/null; then | |
cat <<-EOF | |
I'm not being run from inside a git repository. | |
-- git-fortune.sh | |
EOF | |
exit 1 | |
fi | |
git rev-list --all \ | |
| cut -f1 -d' ' \ | |
| sort -R \ | |
| head -n 1 \ | |
| git rev-list \ | |
--no-walk \ | |
--no-commit-header \ | |
--stdin \ | |
--format="format:%s%b%n%n -- %an" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment