Sublime Text 2 and Bower

If you're not familar with Bower, it's a package manager and it's awesome so it's on GitHub - https://github.com/twitter/bower.

It’s just got even more awesome thanks to @benschwarz.

Ben has built a plugin that allows you to harness Bower’s power from within Sublime Text 2 /germanforblack.com/post/46734908388/i-built-a-plugin-for-sublime-text-that-integrates (no longer online).

Say you've started up a new project and you need to go get a package or dependency such as jQuery.

You open your browser, go to the jQuery site, download / copy and paste the file and save it to your project. Then you need something else, Modernizr, so you go back to your browser, go to the Modernizr site and repeat the process for everything you need. That's ok, it works, but there's a better way.

You'll need Sublime Package Control, if you don’t have that you can get it here:

https://wbond.net/sublime_packages/package_control

With that installed open Sublime Text 2, then shift + cmd + p, type install, select Package Control: Install Package, type bower, hit enter to install Bower.

Open up Terminal and run:

1
npm install bower -g

If it fails, try running as admin by adding sudo:

1
sudo npm install bower -g

Now with Sublime Text 2 you can do shift + cmd + p, type bower, select Bower:Install hit enter.

Boom! You can now search for whatever you want jQuery, Modernizr etc… hit enter again and it will download it for you.

It also creates a handy JSON file that allows you to easily view what's been installed with Bower and much more.

Browse by category: