Last active
December 13, 2019 16:35
-
-
Save dagezi/bf91c9e7d5c5307c5b47ebd674328c7c to your computer and use it in GitHub Desktop.
The small shell script to show git branches in recently-used order.
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 -e | |
function show_latest_branches () { | |
git branch | \ | |
sed 's/[* ]//g; s/.*/printf "& "; git show --format="%at" -s &/'| \ | |
sh | \ | |
sort -k2nr | |
} | |
case "$1" in | |
-v) # verbose; | |
show_latest_branches | |
;; | |
*) | |
show_latest_branches | cut -d ' ' -f 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment