Introducing Nettuts+ Fetch

Introducing Nettuts+ Fetch

In addition to producing various helpful apps for web developers, in 2012, we’ll also be commissioning and releasing smaller plugins and extensions. Today, I’d like to announce the first entry in this initiative: “Nettuts+ Fetch” – a Sublime Text plugin.


The 20 Second Example


Choose 720p for a clearer picture.

The Dilemma

Let’s say that you’re a fan of Normalize.css. Perhaps, you download it and save it to a snippet, or store the stylesheet, itself, in an assets folder. That way, for future projects, you only need to copy and paste.

The only problem with this method – as we’ve all discovered – is that, if a few months have passed, it’s more than possible that the asset (in this case, Normalize.css) will have been updated by the creator. So your options are to either use the, now, out-dated version of Normalize, or, once again, return to the GitHub page and pull in a fresh copy. This all seems tedious.


The Solution

Created by Weslly Honorato, Nettuts+ Fetch is the solution to our dilemma.

I thought to myself: “What if there was a plugin that would automatically pull in the latest copy of a file, simply by typing a keyboard shortcut. It’ll perform a curl request to your specified URL (saved away for future use), and allow you to rest assured that, for all new projects, you’re using the latest copy of a particular asset.

Created by Weslly Honorato, Nettuts+ Fetch is the solution to our dilemma.


Installation Instructions

Nettuts+ Fetch

While you can manually download Nettuts+ Fetch from GitHub, the easiest way to set it up is through Package Control (which all ST2 users should be using). Once you’ve installed package control, press ctrl+shift+p (Windows, Linux) or cmd+shift+p (OS X), and type “Package Install.” Next, search for “Nettuts+ Fetch,” press enter, and you’re done. Simple.


Usage

You’ll only use two commands, when working with Fetch. First, we need to save some file references. Again, bring up the command palette, and search for “Fetch.” For now, choose “Manage Remote Files.”

Manage Remote Files

What’s great about Sublime Text 2 is that configuration is incredibly simple. To assign references to online asset files, we only need to create an object, like so (don’t worry; one will be pre-populated for you, after installation):

So, to pull in the latest copy of jQuery (if you don’t want to use a CDN):

{
	"files":
	{
		"jquery": "http://code.jquery.com/jquery.min.js"
	}
}

Packages

Even better, I can pull in entire packages, or zip files. What if we want to start a new project, using HTML5 Boilerplate? In that case, we add the reference to the “packages” object.

{
	"files":
	{
		"jquery": "http://code.jquery.com/jquery.min.js"
	},
	"packages":
	{
		"html5-boilerplate": "http://github.com/h5bp/html5-boilerplate/zipball/v2.0stripped"
	}
}

Fetch, Boy

Now that we have a package and script saved (add as many as you like), we can pull them in by using the Fetch command. Pull up the command palette – ctrl+shift+p (Windows, Linux) or cmd+shift+p (OS X) – type “Fetch,” and make your selection.

Choose HTML5 Boilerplate from the list, give it a few seconds, and, bam, you’re ready to go with the latest release.

Pretty sweet, huh? I hope you like it! Thanks again to Weslly Honorato for building it for us.

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://www.agnelwaghela.wordpress.com/ Agnel Waghela

    Hi Jeff, I have a Request, is it possible to release or create Nettuts Fetch plugin for Notepad++ Editor?

    Waiting for your reply!

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      Sure!

      • http://whimsycoll.com Whimsy Collective

        Curious; how’s the development of the plugin for Notepad++ coming along?

  • http://www.namagasht.ir آژانس گردشگری

    That’s so cool, but how many fetch apps would be available?

  • Adrian

    Im not sure what im doing wrong, but i dont get anything when typing Nettuts in the Package Control drop down.
    I updated my repositories to this
    https://sublime.wbond.net/repositories.json

    I have the latest 64bit build 2181 on windows

    • http://www.gpc.edu Bruce

      From the Sublime 2 Preferences menu select Package Control. A list should appear with many list items each of which begin with “Package Control: ” and one of them reads “Package Control: Install Package”. Click on that one.
      From there, you can enter “Nettuts+ Fetch” to filter the list leaving only the Fetch plugin visible. Click on it to install it into Sublime 2.

  • http://www.thinkers.it Antonio

    Hi Jeff,
    is it possible to have packages point to a branch on a remote repository url instead of hardcoding the url to the zip package, so we can always fetch the latest branch from github/bitbucket/beanstalk? (clone a repository instead of downloading and unzip the archive)

  • Francisc

    Fetch fetches the contents of a Single File inside the currently open file.
    Is it possible to have it create a file with that name and maybe prompt for where to save it?

  • Artur Kwiatkowski

    This is amazing!

    I was always manually downloading the initializr package from http://www.initializr.com, configuring it etc. and now I can fetch it whenever I want by just adding this single line:

    “initializr”: “http://www.initializr.com/builder?mode=less&boot-hero&jquerymin&h5bp-iecond&modernizrrespond&izr-emptyscript&boot-css&boot-scripts”

    and then fetch command – Im trully amazed :D

  • http://wiki.leworm.fr philippe

    Hello

    The package control doesn’t work for me.
    i add the reposotory : https://github.com/weslly/Nettuts-Fetch
    the soft say : succed add

    after i use install but i have a popup after the load repositories : “package Control : There are no packages available for installation

  • http://www.mayhemdesignstudio.co.uk tyrone

    HI,

    I can pull packages using fetch, but files don’t work. Is anyone else having this problem?

    Here is the code:

    {
    “packages”:
    {
    “bootstrap”: “https://github.com/twitter/bootstrap/zipball/master”,
    “foundation”: “https://github.com/zurb/foundation/downloads/zipball/master”,
    “html5_boilerplate”: “https://github.com/h5bp/html5-boilerplate/zipball/master”,
    “initializr”: “https://github.com/verekia/initializr-template/zipball/master”,
    “skeleton”: “https://github.com/dhgamache/Skeleton/zipball/master”
    },

    “files”:
    {
    “modernizr”: “https://github.com/Modernizr/Modernizr/zipball/master”,
    “jquery”: “http://code.jquery.com/jquery.min.js”,
    “jquery-latest 1.x.”: “http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js”,
    “jquery–Latest 1.x–minified”: “http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”,
    “normalize”: “https://raw.github.com/necolas/normalize.css/master/normalize.css”,
    “reset”: “http://meyerweb.com/eric/tools/css/reset/reset.css”
    }
    }

    • http://sebastiangraz.com Sebastian Graz

      I think your using curly quotes? Them quotes should be straight if you ask me. (“”) – Your using (“”)

    • el_diablo

      files handles have “-” in them, change for “_”, works for me

  • http://www.felipepadilla.com ziraga

    Fetch “packages” is not working with certain git repos.
    it leaves a __tmp_package.zip inside the folder created.

    Best example of this bug is philippe’s, using weslly’s master repo.

    https://github.com/weslly/Nettuts-Fetch

    any solutions?

    • http://www.felipepadilla.com ziraga

      slap in the face…

      I was getting the git repo url and not the zipball url

  • Husam

    To get the latest html5 boilerplate v4.0.1 write this:

    “packages”:
    {
    “html5_boilerplate”: “https://github.com/h5bp/html5-boilerplate/zipball/v4.0.1″
    }

  • Eryk Kleinert

    How to import package relativly to current project’s directory? (Windows)

  • tmfsd

    Is there any way to get this to work behind a corporate proxy?

  • omid reyhani

    To get files and packages localy use file:/// protocol like file:///path_to_the_file

  • http://www.facebook.com/thoma.big Thoma Bebop

    Hi Jeffrey,
    Do you know if there is a way to use the Fetch package with sublime text 3 ?

    Thanks !

  • garrett

    AWESOME! Thanks! Keeps me up to date with Twitter Bootstrap, Parse, Jquery UI………..
    Super easy too!

  • devoth

    Hi guys, I’m having some problems with getting fetch to work with Sublime Text 3. In CMD+SHIFT+P menu I can choose only “Fetch: Manage”, I can’t seem to be able to use the configured packages – there is no “Fetch” in Command Palette.

    Is Fetch only supposed to work with Sublime 2 or might this be a different error?

  • http://joshmedeski.com/ Josh Medeski

    FYI, it’s not working for Sublime Text 3.