Coder Social home page Coder Social logo

vscode-command-runner's Introduction

VSCode Command Runner

Run custom shell command defined in vs code configuration and node module package.json

Features

  • Run custom shell command
  • Run selected content as shell command
  • Run custom shell command with selected files by explorer context menu

Extension Settings

You can defined shell command in vs code configuration

{
    "command-runner.terminal.name": "runCommand",
    "command-runner.terminal.autoClear": true,
    "command-runner.terminal.autoFocus": true,
    "command-runner.commands": {
        "echo workspaceFolder": "echo ${workspaceFolder}",
        "echo file": "echo ${file}"
    }
}

or in node module package.json

{
    "commands": {
        "echo workspaceFolder": "echo ${workspaceFolder}",
        "echo file": "echo ${file}"
    }
}

Key Binding

You can bind custom keys for the command which defined in configuration

{
    "key": "ctrl+alt+1",
    "command": "command-runner.run",
    "args": { "command": "echo file" }
}

Terminal Options

You can customize the terminal for the command

{
    "key": "ctrl+alt+1",
    "command": "command-runner.run",
    "args": {
        "command": "echo file",
        "terminal": "runCommand"
    }
}

or

{
    "key": "ctrl+alt+1",
    "command": "command-runner.run",
    "args": {
        "terminal": {
            "name": "runCommand",
            "cwd": "path/to/runCommand",
            "shellArgs": [],
            "autoClear": true,
            "autoFocus": true
        }
    }
}

Predefined Variable

  • ${file}: activated file path;
  • ${fileBasename}: activated file basename;
  • ${fileBasenameNoExtension}: activated file basename with no extension;
  • ${fileDirname}: activated file dirname;
  • ${fileExtname}: activated file extension;
  • ${lineNumber}: the first selected line number;
  • ${lineNumbers}: the all selected line number, eg. 41,46,80;
  • ${selectedText}: the first selected text;
  • ${selectedTextList}: the all selected text list, eg. sl1 sl2;
  • ${selectedTextSection}: the all selected text section, eg. sl1\nsl2;
  • ${selectedPosition}: the selected position list, eg. 21,6;
  • ${selectedPositionList}: the all selected position list, eg. 45,6 80,18 82,5;
  • ${relativeFile}: activated file relative path;
  • ${workspaceFolder}: activated workspace folder path;
  • ${workspaceFolderBasename}: activated workspace folder basename;
  • ${homedir}: the home directory of the current user;
  • ${tmpdir}: default directory for temporary files;
  • ${platform}: os platform;
  • ${env:PATH}: shell environment variable "PATH";
  • ${config:editor.fontSize}: vscode config variable;
  • ${command:workbench.action.terminal.clear}: run vscode command;
  • ${input}: input a value as parameter;
  • ${input:defaultValue}: input a value as parameter, and specify the default value;

Usages

  • use shortcut Ctrl+Shift+R to select custom command
  • use shortcut Ctrl+Alt+R to run selected content as shell command
  • or press F1 and then select/type Run Command or Run In Terminal,
  • or right click the Text Editor and then click Run Command to select custom command in editor context menu
  • or right click the Text Editor and then click Run In Terminal to run selected content as shell command in editor context menu

vscode-command-runner's People

Contributors

edonet avatar dependabot[bot] avatar arcanis avatar

Watchers

James Cloos 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.