The Big Picture

Registering the command

First thing to do is to register the command inside Brackets, which comes in three parts:


  1. This is the string that will be displayed on the menu item
  2. A unique string identifier to ensure that your command name will not be similar to someone else's
  3. The function that will house the code for your extension's functionalities

Creating the context menu

The Detail

Create a file named main.js—which is inside its own parent— folder, which, in turn, is inside the user folder, which, is in the extensions folder as illustrated below:

Put these codes inside the main.js file:

define(function (require, exports, module) {
    "use strict";

    var CommandManager = brackets.getModule("command/CommandManager"),
        Menus          = brackets.getModule("command/Menus");

    function init() {

        var cmdIdentifier = "islandjoe.context-menu";

        CommandManager.register("Context Menu", cmdIdentifier, doThisWhenClicked);

        var fileTreeMenu = Menus.getContextMenu( Menus.ContextMenuIds.PROJECT_MENU );


        fileTreeMenu.addMenuItem( cmdIdentifier );


    function doThisWhenClicked() {
        // code for the functionality here


Then finally, reload Brackets and its extensions (⌘R).

In order to be complete, you can add,, and package.json.