Last Updated: February 20, 2016
·
1.489K
· darkhelmet

bash brace expansion for less typing

Named a file wrong? Need to move it to another directory? No big deal. What if you named a view file foo.haml instead of the proper foo.html.haml?

mv app/views/widgets/foo.{haml,html.haml}

Does exactly what you think it does. It expands to:

mv app/views/widgets/foo.haml app/views/widgets/foo.html.haml

Since it's just bash, it also works with git:

git mv app/views/widgets/foo.{haml,html.haml}

Works within the path too:

git mv app/views/{widget,whatsit}/foo.html.haml