github用プロジェクトの雛形をシェルでサクッと用意する

## 動機 
* `git init`したり`README.md`用意したり、ってあたりをコマンド一発でサクッとやりたい
* もっと細かい事・丁寧な事をやりたければ好きな言語でコマンドラインツール作るとかすればいいと思う。その際の参考にでもなれば


## やること
以下をシェルで
* `README.md` を作成する
* `CHANGELOG` を作成する
* `LICENSE` を作成する
* `.gitignore`を作成する
* `git init`する
* （後で必要に応じて）README.mdに各種ステータスバッジを追加する


## .zshrc, .bashrc あたりに設定追記
`.zshrc`とか`.bashrc`に下記を追記

```bash
function ghreadme() {
  account=$1
  name=$2

  cat <<EOL
${name}
==========
${name} is hoge huga.


## Getting Started


## Usage


## Contact

* Bugs: [issues](https://github.com/${account}/${name}/issues)


## ChangeLog
[CHANGELOG](CHANGELOG) file for details.


## License

[LICENSE](LICENSE) file for details.
EOL
}


function ghchangelog() {
  account=$1

  cat <<EOL
v0.0.1
* Initial commit

Contributors:
* YOUR_NAME (@${account})
EOL
}


function ghmit() {
  account=$1
  year=$(date +"%Y")

  cat <<EOL
The MIT License (MIT)

Copyright (c) ${year} ${account}

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
EOL
}


function gitignore() {
  cat <<EOL
.DS_Store
*.swp
*.log
EOL
}


function ghinit() {
  account=$1
  name=$2

  ghreadme ${account} ${name} > README.md
  ghchangelog ${account} ${name} > CHANGELOG
  ghmit ${account} > LICENSE

  gitignore > .gitignore
  git init
}


function ghaddbadge() {
  account=$1
  name=$2
  t=$3

  if [ ! -f README.md ]
  then
    echo "Not exist README.md"
    return 1
  fi

  current=$(head -n 1 README.md)
  exheader=$(tail -n +2 README.md)

  case ${t} in
    "mit")
      add=" [![MIT License](http://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/${account}/${name}/blob/master/LICENCE)"
      ;;
    "drone")
      add=" [![Build Status](https://drone.io/github.com/${account}/${name}/status.png)](https://drone.io/github.com/${account}/${name}/latest)"
      ;;
    "godoc")
      add=" [![GoDoc](https://godoc.org/github.com/${account}/${name}?status.png)](https://godoc.org/github.com/${account}/${name})"
      ;;
    *)
      echo "type is not supported: ${t}"
      ;;
  esac

  echo "${current}${add}" > README.md
  echo "${exheader}" >> README.md
}
```


## 使い方

```shell-session
$ mkdir hoge
$ cd hoge
$ ghinit YOUR_GITHUB_ACCOUNT YOUR_PROJECT_NAME 
```

* README.mdに色んなサービスのステータス・バッジを追加する

```shell-session
$ ghaddbadge YOUR_GITHUB_ACCOUNT YOUR_PROJECT_NAME [mit|drone|godoc|(other)]


# 例えば "mit" を指定した場合、README.md先頭行に↓こんな感じで追記される
(before) hoge
(after)  hoge [[!MIT License](http://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/YOUR_GITHUB_ACCOUNT/YOUR_PROJECT_NAME/blob/master/LICENCE)
```