Giter VIP home page Giter VIP logo

vscode-save-and-run's Introduction

Run saved file in Terminal

Fork from vscode-runonsave

Simplify original extension by pass command into Terminal directly without spawn process, so we don't lose output colors.

Features

  • Configure multiple commands that run when a file is saved
  • Regex pattern matching for files that trigger commands running

Configuration

Add "saveAndRun" configuration to user or workspace settings.

  • "commands" - Array of commands that will be run whenever a file is saved.
  • "match" - A regex for matching which files to run commands on
  • "cmd" - Command to run. Can include parameters that will be replaced at runtime (see Placeholder Tokens section below).
  • "useShortcut" - Execute file with shortcut key Command + Shift + R

Sample Config

"saveAndRun": {
  "commands": [
    {
      "match": ".*",
      "cmd": "echo 'I run for all files.'",
      "useShortcut": false,
      "silent": false
    },
    {
      "match": "\\.txt$",
      "cmd": "echo 'I am a .txt file ${file}.'",
      "useShortcut": false,
      "silent": false
    }
  ]
}

Commands

The following commands are exposed in the command palette

  • Save and Run : Enable
  • Save and Run : Disable

Placeholder Tokens

Commands support placeholders similar to tasks.json.

  • ${workspaceRoot} - workspace root folder
  • ${workspaceFolder} - the path of the folder opened in VS Code
  • ${file} - path of saved file
  • ${relativeFile} - relative path of saved file
  • ${fileBasename} - saved file's basename
  • ${fileDirname} - directory name of saved file
  • ${fileExtname} - extension (including .) of saved file
  • ${fileBasenameNoExt} - saved file's basename without extension
  • ${cwd} - current working directory

Environment Variable Tokens

  • ${env.Name}

License

Apache

vscode-save-and-run's People

Contributors

artem-sidorenko avatar bmingles avatar hsiaosiyuan0 avatar saml avatar victorporof avatar wk-j avatar

Watchers

 avatar  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.