Skip to content

Commit

Permalink
Added testing if the home dir. Added to create a git repo in the sub dir
Browse files Browse the repository at this point in the history
  • Loading branch information
shinokada committed May 21, 2021
1 parent 5dcc6d0 commit d9c19d4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion gitstart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ done

############# Main body ############

# don't allow to create a git repo in the ~
# user may use . in the HOME
cwd=$(pwd)
if [[ (${dir} = $HOME) || ($cwd = $HOME && ${dir} = ".") ]]; then
echo "This script doesn't allow to create a git repo in the home directory."
echo "Use another directory."
exit 1
fi

# if dir is empty exit
if [[ -z ${dir} ]]; then
echo "You must set -d dir_name."
Expand All @@ -102,6 +111,7 @@ user=$(yq e '."github.com".user' "$HOME"/.config/gh/hosts.yml)
repo=$(basename "${dir}")
license_url="mit"
echo ">>> Your github username is ${user}."
echo ">>> Your new repo name is ${repo}."

PS3='Your lisence: '
lisences=("MIT: I want it simple and permissive." "Apache License 2.0: I need to work in a community." "GNU GPLv3: I care about sharing improvements." "None" "Quit")
Expand Down Expand Up @@ -159,7 +169,7 @@ if [[ ${prog_lang} ]]; then
fi
echo "${dir}"
echo ">>> Creating ${dir}."
mkdir "${dir}" || exit
mkdir -p "${dir}" || exit
cd "${dir}" || exit
echo ">>> Creating READMR.md."
printf "# %s \n
Expand Down

0 comments on commit d9c19d4

Please sign in to comment.