LoginSignup
6
6

More than 5 years have passed since last update.

README.mdを予め作るシェルスクリプトを作る

Posted at

README.mdにいつもGemnasiumやTravisCIのバッジをくっつけてますけども、
毎回この作業やるのしんどいので、シェルスクリプトで一発!!ってなるようにしました。

なお、current_repositoryとかは、oh-my-zshのgitプラグインをそのまま利用しています。

makereadme
#!/bin/zsh
CURRENT_REPOSITORY () {
    ref=$(git symbolic-ref HEAD 2> /dev/null)  || ref=$(git rev-parse --short HEAD 2> /dev/null)  || return
    echo $(git remote -v | cut -d':' -f 2)
}

CURRENT_REPOSITORY_USER_NAME () {
    echo ${$(CURRENT_REPOSITORY | awk '{print $1}')%.git}
}

CURRENT_REPOSITORY_DIRECTORY=`git rev-parse --show-toplevel`
CURRENT_REPOSITORY_NAME=$(basename $CURRENT_REPOSITORY_DIRECTORY)
rm README.md

touch README.md
cat << EOT >> README.md
${CURRENT_REPOSITORY_NAME}
===============

[![Build Status](https://travis-ci.org/$(CURRENT_REPOSITORY_USER_NAME).png)](https://travis-ci.org/$(CURRENT_REPOSITORY_USER_NAME))
[![Dependency Status](https://gemnasium.com/$(CURRENT_REPOSITORY_USER_NAME).png)](https://gemnasium.com/$(CURRENT_REPOSITORY_USER_NAME))

EOT
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6