Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v1.48.8
Fetching contributors…

Cannot retrieve contributors at this time

executable file 111 lines (93 sloc) 2.746 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
#!/bin/bash

USERNAME=$(git config user.name)
EMAIL=$(git config user.email)
LEVEL="global"
CLEVEL="global"

fWelcome() {
    clear
    echo "======================================================="
    echo " _ _ _ _ _ _____ _ _______ _ _______ "
    echo "| || || | | | (_____) | | (_______) | (_______)"
    echo "| || || | |__ | | _ \ \ _ | | _____ "
    echo "| ||_|| | __)| | | | \ \| | | | | ___) "
    echo "| |___| | | | |_| |_ _____) ) |_____| |_____| |_____ "
    echo " \______|_| |_(_____|______/ \______)_______)_______)"
    echo " - - - Signaling the start of next generation telephony"
    echo "======================================================="
    echo
}

fGetUsername() {
    USERNAME=$(git config ${CLEVEL}user.name)
    read -p "Enter the name to use on git commits [$USERNAME]: " RESP
    if [ ! -z "$RESP" ]; then
        USERNAME="$RESP"
    fi
}

fGetEmail() {
    EMAIL=$(git config ${CLEVEL}user.email)
    read -p "Enter the email to use on git commits [$EMAIL]: " RESP
    if [ ! -z "$RESP" ]; then
        EMAIL="$RESP"
    fi
}

fConfigLevel() {
    while true; do
        read -p "What level config do you want to change system, global, or repository? (s/g/r)[$LEVEL]:" -n 1 RESP
        if [ -z "$RESP" ]; then
            break
fi
        echo
case $RESP in
            [Ss]* ) LEVEL="system";break;;
            [Gg]* ) LEVEL="global";break;;
            [Rr]* ) LEVEL="repository";break;;
            * ) clear;fWelcome;;
        esac
    done
    if [ "$LEVEL" = "repository" ]; then
        CLEVEL=""
    else
        CLEVEL="--$LEVEL "
    fi
}

fGetEditor() {
    read -p "Enter the editor to use for git commit messages [$EMAIL]: " RESP
    if [ -z "$USERNAME" ]; then
        EDITOR="$(whoami)"
    else
        EDITOR="$RESP"
    fi
}

fSetupUser() {
    echo "# git config ${CLEVEL}user.name \"$USERNAME\""
    git config ${CLEVEL}user.name "$USERNAME"

    echo "# git config ${CLEVEL}user.email $EMAIL"
    git config ${CLEVEL}user.email "$EMAIL"
}

fEnableRerere() {
    echo "# git config ${CLEVEL}rerere.enabled 1"
    git config ${CLEVEL}rerere.enabled 1
}

fEnableColor() {
    echo "# git config ${CLEVEL}color.ui true"
    git config ${CLEVEL}color.ui true
}

fLineEndingPrefs() {
  echo "# git config ${CLEVEL}core.autocrlf input"
  git config ${CLEVEL}core.autocrlf input
  # git config --global core.autocrlf true ## Windows

  echo "# git config ${CLEVEL}core.safecrlf true"
  git config ${CLEVEL}core.safecrlf true
}

cd `dirname $0`

clear

fWelcome
fConfigLevel
fGetUsername
fGetEmail

fSetupUser
fEnableRerere
fEnableColor
fLineEndingPrefs

echo "Git configuration complete."

exit 0
Something went wrong with that request. Please try again.