Skip to content

Bash Exansion

In my view, this is pretty straightforward. Sometimes when I need to install a lot of dependencies all at the same time (I'm looking at you gulp and webpack) I get frustrated. It's kind of a hassle to write out

$ npm install --save-dev gulp gulp-sass gulp-otherthing gulp-more # etc...

Fortunately bash expansion can really cut down on this. The syntax for bash expansion goes like this:

$ mainThing{-one,-two,-three}

That will yield

$ mainThing-one mainThing-two mainThing-three

So, if I want to echo in the terminal something silly like pies that have been turned into url slugs...

$ echo {apple,peach,blueberry}-pie
$ apple-pie peach-pie blueberry-pie

So how is that actually useful? Getting back to gulp and its myriad plugins

$ npm install --save-dev gulp gulp-{plugin1,plugin2,plugin3}
$ # installs gulp gulp-plugin1 gulp-plugin2 gulp-plugin3

I hope you like this little tip!

Read More Articles:Post Tags:Photo By:

Tomas Sobek