LoginSignup
10
10

More than 5 years have passed since last update.

コードリーディングをすぐに始めるためのcrコマンドを作った

Last updated at Posted at 2015-05-09

Rubyのgemのソースコードを効率的に読む方法 - ブログのおんがえしを自動化するためのスクリプトを書きました。~/.bashrcに追加します。

# Setup Code Reading
# ex. cr https://github.com/ongaeshi/milkode.git
cr() {
    local repo=$1
    local basename=`basename $1`
    local dir=${basename%.*}

    git clone $repo
    cd $dir
    git checkout -b codereading

    milk add .
    milk config update_with_ctags_e true
    milk update

    pwd
}

使い方

cr チェックアウトしたいソースコードです。

  1. git clone
  2. codereadingブランチの作成
  3. milkodeにデータベース追加
  4. ctagsファイルの作成

をまとめて行ってくれます。

# .bashrcに上記コマンドを追加
$ source ~/.bashrc
$ cd ~/Documents
$ cr https://github.com/ongaeshi/milkode.git
Cloning into 'milkode'...
remote: Counting objects: 9906, done.        
remote: Total 9906 (delta 0), reused 0 (delta 0), pack-reused 9906        
Receiving objects: 100% (9906/9906), 5.59 MiB | 1.16 MiB/s, done.
Resolving deltas: 100% (4254/4254), done.
Checking connectivity... done.
Switched to a new branch 'codereading'
.
.
result     : 1 packages, 119 records, 119 update. (0.46sec)
*milkode*  : 34 packages, 8264 records in /Users/ongaeshi/.milkode/db/milkode.db.
/Users/ongaeshi/Documents/milkode

Milkodeデータベースの作成は要らない、タグファイルはetags派などはお好みで改造してください。

10
10
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
10
10