mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
75 lines
1.5 KiB
Bash
Executable file
75 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
get_config() {
|
|
cmd_get_config="$(git config --get-all git-extras.info.config-grep)"
|
|
if [ -z "$cmd_get_config" ]; then
|
|
git config --list
|
|
else
|
|
eval "$cmd_get_config"
|
|
fi
|
|
}
|
|
|
|
most_recent_commit() {
|
|
cmd_get_log="$(git config --get-all git-extras.info.log)"
|
|
if [ -z "$cmd_get_log" ]; then
|
|
git log --max-count=1 --pretty=short
|
|
else
|
|
eval "$cmd_get_log"
|
|
fi
|
|
}
|
|
|
|
submodules() {
|
|
# short sha1
|
|
git submodule status | sed 's/\([^abcdef0-9]\{,2\}\)\([abcdef0-9]\{7\}\)\([abcdef0-9]\{33\}\)\(.*\)/\1\2\4/'
|
|
}
|
|
|
|
local_branches() {
|
|
git branch
|
|
}
|
|
|
|
remote_branches() {
|
|
git branch -r
|
|
}
|
|
|
|
remote_urls() {
|
|
git remote -v
|
|
}
|
|
|
|
echon() {
|
|
echo "$@"
|
|
echo
|
|
}
|
|
|
|
GREEN="$(tput setaf 2)"
|
|
NORMAL="$(tput sgr0)"
|
|
if [ "$1" = "--color" ] || [ "$2" = "--color" ] || \
|
|
[ "$1" = "-c" ] || [ "$2" = "-c" ] ; then
|
|
COLOR_TITLE="$GREEN"
|
|
else
|
|
COLOR_TITLE="$NORMAL"
|
|
fi
|
|
|
|
echo
|
|
echon "${COLOR_TITLE}## Remote URLs:${NORMAL}"
|
|
echon "$(remote_urls)"
|
|
|
|
echon "${COLOR_TITLE}## Remote Branches:${NORMAL}"
|
|
echon "$(remote_branches)"
|
|
|
|
echon "${COLOR_TITLE}## Local Branches:${NORMAL}"
|
|
echon "$(local_branches)"
|
|
|
|
SUBMODULES_LOG=$(submodules)
|
|
if [ ! -z "$SUBMODULES_LOG" ]; then
|
|
echon "${COLOR_TITLE}## Submodule(s):${NORMAL}"
|
|
echon "$SUBMODULES_LOG"
|
|
fi
|
|
|
|
echon "${COLOR_TITLE}## Most Recent Commit:${NORMAL}"
|
|
echon "$(most_recent_commit)"
|
|
|
|
if [ "$1" != "--no-config" ] && [ "$2" != "--no-config" ]; then
|
|
echon "${COLOR_TITLE}## Configuration (.git/config):${NORMAL}"
|
|
echon "$(get_config)"
|
|
fi
|