Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -e
- GIT_OPTS="--max-count=10"
- commit_id_format=$(tput setaf 3)
- date_format=$(tput setaf 4)
- author_format=$(tput setaf 2)
- ref_name_format=$(tput setaf 1)
- reset=$(tput sgr0)
- function usage() {
- echo ""
- echo "git activity [-c|--count <number>] [--no-color] [--fetch]"
- echo ""
- echo " List commit logs sorted by commit date."
- echo ""
- echo "OPTIONS"
- echo " --fetch"
- echo " Fetch download objects and refs from all the remotes that are configured."
- echo " --no-color"
- echo " Turn off colored output."
- echo " --c | --count <number>"
- echo " Limit the output to <number> of entries."
- }
- # actually parse the options and do stuff
- while [[ $1 = -?* ]]; do
- case $1 in
- -h|--help)
- usage
- exit 0
- ;;
- --fetch)
- echo "Fetch updates"
- git fetch -q
- ;;
- -c|--count)
- shift
- limit=${1-"10"}
- GIT_OPTS="--max-count=${limit}"
- ;;
- --no-color|--no-colour)
- commit_id_format=""
- date_format=""
- author_format=""
- ref_name_format=""
- reset=""
- ;;
- *) ;;
- esac
- shift
- done
- # Use newline as a field separator
- IFS=$(echo -en "\n\b")
- for line in $(git --no-pager log --format="%ar|%h|%an|%s|%d" ${GIT_OPTS}); do
- fields=(`echo $line | tr "|" "\n"`)
- printf "${date_format}%15s${reset} ${commit_id_format}%s${reset} - ${author_format}[%s]${reset} %s${ref_name_format}%s\n" ${fields[*]}
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement