Code Monkey home page Code Monkey logo

st-contextshellcommand's Introduction

ContextShellCommand

ContextShellCommand is a Sublime Text plugin, which support dynamic context menu (right-click menu).

By modifying the settings file, users can bind external commands to right-click menu items or shortcuts, so that the corresponding external commands can be executed easily with the right mouse button or shortcuts.

Installation

This plugin depends on the dctxmenu plugin. Before installing this plugin, you must install dctxmenu plugin.

The following steps assume that you already have Package Control installed.

  1. Copy the URL of this repository: https://github.com/absop/ContextShellCommand
  2. Enter into Sublime Text, press down the shortcut Ctrl+Shift+P to enter into Command Palette
  3. Input the command pcar(Package Control: Add Repository)
  4. Press down the shortcut Ctrl+V, then Enter
  5. Using Package Control to install this package
    1. Press down Ctrl+Shift+P
    2. Input pcip(Package Control: Install Package)
    3. Input ContextShellCommand

Bind External Commands to The Right-click Menu

You can using the command palette to type and execute the command Preferences ContextShellCommand Settings, or click on the main menu (Preferences>Package Settings> ContextShellCommand >Settings), to begin editing the settings.

You can add a menu sub-item to the right-click menu by adding a command-map to the commands entry, which is one of the two setting entires of this plugin, the other is caption.

Here's an example

{
    "caption": "Run Shell Cmd",

    "commands": [
        {
            "caption": "Github Desktop Here",
            "command": ["github.bat", "${file_path}"],
            "shell": true,
            // "show_output_panel": false
        },
        {
            "caption": "Cmder Here",
            "command": ["Cmder.exe", "${file_path}"],
            "shell": true,
            // "show_output_panel": false
        },
        {
            "caption": "List Files",
            "command": ["dir", "${file_path}"],
            "shell": true,
            "platform": "Windows",
            "encoding": "gbk"
        }
    ]
}

Where commands is a list of command-maps.

Each command-map is a dictionary (Dict, or Map), where caption is the title of the corresponding command displayed in the menu, and command is the specific command to be executed. Please refer to the above example to fill in carefully. command can be a string, or a list of strings, the strings of command can contain some variables (reference Sublime Text API documentation, search extract_variables) and these variables will be replaced with their corresponding values when the command is executed.

In addition, command-map supports a optional argument called shell with a boolean value, which defaults to true and is passed to subprocess and is not normally used.

An entry in commands directly corresponds to a menu item. When there are multiple menu items, the menu will be folded and the folded menu will be titled with the value of the caption of the same level as commands. When there is only one command-map in commands, only one top-level menu is added to the right-click menu.

The following screen-shot shows the two menu sub-items were added to the right-click menu with using the example settings above.

Binding Shortcuts

By editing your personal keymap file (Preferences>Key Bindings), you can also bind specific external commands to shortcuts, so that you can use shortcuts to execute external commands in Sublime Text. Here's an example

{
    "keys": ["ctrl+alt+t"],
    "command": "execute_shell_command",
    "args": {
        "command": ["Cmder.exe", "\"${file_path}\""],
        "shell": true,
        // "show_output_panel": false
    }
}

You can copy this example and modify the "keys" and "args" entries. The value of "args" is a command-map, except that the caption entry will be ignored.

st-contextshellcommand's People

Contributors

absop avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.