51
48

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

1分で実現できる有用な技術Advent Calendar 2014

Day 22

Brace Expansionで生産性5割増しな楽しいコマンドライン生活

Last updated at Posted at 2014-12-26

10秒で出来ますが,生活は50%ぐらい豊かになります.

かんたんな使い方

例その①: リネームめんどくさい

たとえばこんなとき

console
$ rails g controller user  # あっ まちがって s つけわすれちゃった

リネームめんどくさいですよね

console
$ mv app/controllers/user_controller.rb app/controllers/users_controller.rb

こんなときにBrace Expansion!

console
# {,s} を展開してくれるので,先のコマンドと同じ結果になる
$ mv app/controllers/user{,s}_controller.rb

これだけでちゃんとリネームできちゃいます.

例その②: ディレクトリ作成めんどくさい

AngularJSつかうぞ〜〜〜

console
$ mkdir app/assets/javascripts/controllers
$ mkdir app/assets/javascripts/directives
$ mkdir app/assets/javascripts/filters
$ mkdir app/assets/javascripts/services

…めんどくさい.

こんなときにもBrace Expan(ry

console
$ mkdir app/assets/javascripts/{controller,directive,filter,service}s

これでOK!

例その③: 連番ファイル作成めんどくさい

連番ディレクトリ作るぞ〜〜〜

console
$ mkdir app/assets/images/photos-A
$ mkdir app/assets/images/photos-B
$ mkdir app/assets/images/photos-C
$ mkdir app/assets/images/photos-D
$ mkdir app/assets/images/photos-E
$ mkdir app/assets/images/photos-F

やっぱりめんどくさい.

そんなときにも(ry

$ mkdir app/assets/images/photos-{A..F}

これだけでいける!

まとめ

便利ですね.生産性5割増しぐらいですね.
こころぴょんぴょんしますね.

参考URL

51
48
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
51
48

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?