Sha256: 23743c2cb06882d7ba2a8664a47c3a37421f52e6acee8301d4d17421efc2f9f5

Contents?: true

Size: 1.1 KB

Versions: 39

Compression:

Stored size: 1.1 KB

Contents

#!/bin/bash

# Output:
# First argument if it is not blank
# Second argument if first argument is blank
anti_blank () {
  if [ -z "$1" ]; then
    echo "$2"
  else
    echo "$1"
  fi
}

# Setting Git email if necessary
GIT_EMAIL="$(git config user.email)"
if [ -z "$GIT_EMAIL" ]; then
  EMAIL_DEF='you@example.com'
  echo
  echo "Default email address: ${EMAIL_DEF}"
  echo
  echo 'Enter your Git email address:'
  read EMAIL_SEL
  EMAIL=$(anti_blank $EMAIL_SEL $EMAIL_DEF)
  echo

  echo
  echo '------------------------------'
  echo "git config --global user.email"
  echo "$EMAIL"
  git config --global user.email "$EMAIL"
fi

# Setting Git name if necessary
GIT_NAME="$(git config user.name)"
if [ -z "$GIT_NAME" ]; then
  NAME_DEF='Your Name'
  echo
  echo "Default name: ${NAME_DEF}"
  echo
  echo 'Enter your Git name:'
  read NAME_SEL

  # NOTE: The double quotes are needed to avoid truncating the string
  # at the space.
  NAME=$(anti_blank "$NAME_SEL" "$NAME_DEF")

  echo
  echo '-----------------------------'
  echo "git config --global user.name"
  echo "$NAME"
  git config --global user.name "$NAME"
  echo
fi

Version data entries

39 entries across 39 versions & 6 rubygems

Version Path
generic_app-3.0.22 credentials.sh
generic_app-3.0.21 credentials.sh
generic_app-3.0.20 credentials.sh
generic_app-3.0.19 credentials.sh
generic_app-3.0.18 credentials.sh
generic_app-3.0.17 credentials.sh
line_containing-0.1.2 credentials.sh
string_in_file-1.0.2 credentials.sh
insert_from_file-0.0.7 credentials.sh
insert_from_file-0.0.6 credentials.sh
insert_from_file-0.0.5 credentials.sh
string_in_file-1.0.1 credentials.sh
generic_app-3.0.16 credentials.sh
generic_app-3.0.15 credentials.sh
generic_app-3.0.14 credentials.sh
generic_app-3.0.13 credentials.sh
generic_app-3.0.12 credentials.sh
generic_app-3.0.11 credentials.sh
generic_app-3.0.10 credentials.sh
generic_app-3.0.9 credentials.sh