Skip to content

Instantly share code, notes, and snippets.

@cristovaov
Last active November 10, 2022 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristovaov/d9c397016f7d345b157d to your computer and use it in GitHub Desktop.
Save cristovaov/d9c397016f7d345b157d to your computer and use it in GitHub Desktop.
git-it.sh
#!/bin/bash -
#title :git-it.sh
#description :Self destructing Git initialisation script. Self-destruction now optional!
#author :Cristovao Verstraeten - https://gist.github.com/cristovaov/d9c397016f7d345b157d
#date :20150823
#version :2022.11.10
#usage :./git-it.sh
#notes :Commented the self-destructing bits! Added capitalization to commit messages.
#bash_version :4.3.39(3)-release
#============================================================================
# "strict mode"
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
## VARIABLES
currentscript=$0
cwd=$(PWD)
randommessage=$(curl -s -S -L whatthecommit.com/index.txt)
### FUNCTIONS
main(){
# set -x
cd "${cwd}"
# self-destroy
make_a_git_repo
# set +x
}
self-destroy(){
echo "${currentscript} will self-destroy on exit..."
trap finish EXIT
}
init_files() {
cat > .gitignore <<EOF
.idea/
.vagrant/
node_modules/
temp/
EOF
cat > README.md <<EOF
*In the beginning there was nothing...*
EOF
}
finish() {
rm "${currentscript}"
}
make_capitalization(){
capitalized_first_letter=$(echo "${randommessage:0:1}" | tr '[:lower:]' '[:upper:]')
capitalized_message="${capitalized_first_letter}${randommessage:1}"
}
make_a_git_repo(){
git init
init_files
git add .gitignore README.md
make_capitalization
git commit -m "$capitalized_message"
}
### SCRIPT
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment