Script for bootstrapping a new project #bash #git
Creating a new project and publishing it usually involves many repeatitive steps. As developers we like to automate the tedious repetitive tasks to allow our creative juices to flow freely.
I wrote the following script for boostrapping a new project. Feel free to modify and add to your zshrc or bashrc:
function initprj() {
# create the directory and cd into it unless the user uses '.'
# to indicate current directory
if [[ "$1" != "." ]]; then
mkdir $1
cd $1
fi
# setup git
git init
# setup remote repo on github and add it to git remote
hub create
# setup base files (add your own if you'd like)
touch README.md
touch .gitignore
# You must use tabs if you want to indent heredocs that use the <<- syntax
cat <<-EOF > LICENSE
Copyright (c) $(date +"%Y") Dorian Karter
Permission is hereby granted, ...
EOF
}
To run the script simply type initprj my-project
and watch the magic happen.
Note: you must have hub installed to create the remote repo.
Tweet