From 8e519e3e66e897e9eae5faae9101c0f27cde97ae Mon Sep 17 00:00:00 2001 From: Yuriy VG Date: Mon, 24 Aug 2020 11:09:27 +0300 Subject: [PATCH] git-info: moved argument checking --- bin/git-info | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/bin/git-info b/bin/git-info index 7a70f59..86bb4f9 100755 --- a/bin/git-info +++ b/bin/git-info @@ -1,5 +1,19 @@ #!/usr/bin/env bash +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 + +HIDE_CONFIG= +if [ "$1" != "--no-config" ] && [ "$2" != "--no-config" ]; then + HIDE_CONFIG=1 +fi + get_config() { cmd_get_config="$(git config --get-all git-extras.info.config-grep)" if [ -z "$cmd_get_config" ]; then @@ -40,15 +54,6 @@ echon() { 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)" @@ -68,7 +73,7 @@ fi echon "${COLOR_TITLE}## Most Recent Commit:${NORMAL}" echon "$(most_recent_commit)" -if [ "$1" != "--no-config" ] && [ "$2" != "--no-config" ]; then +if [ ! -z "$HIDE_CONFIG" ]; then echon "${COLOR_TITLE}## Configuration (.git/config):${NORMAL}" echon "$(get_config)" fi