Git Product home page Git Product logo

f5anything's Introduction

Lets you put any normal console command or VSCode command into a launch.json configuration so you can run it with F5 (or whatever your normal run/debug keybind is).

Simply install the extension then add a configuration like this to the launch.json file in the .vscode folder of your workspace:

{
    "name": "F5 Anything: My Custom Command",
    "type": "f5anything",
    "request": "launch",
    "command": "echo Put your command here",
}

Replace the echo Put your command here with whatever command you want. It may include variables such as ${file}. When the launch configuration is run, the command will be run in a VSCode integrated terminal.

The full launch.json would look like:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "F5 Anything: My Custom Command",
            "type": "f5anything",
            "request": "launch",
            "command": "echo Put your command here",
        }
    ]
}

VSCode/VSCode Extension Commands

If instead (or additionally) you want to run an internal VSCode command or VSCode extension command (normally accessed from the Ctrl+Shift+P menu), put the command ID as the value of the "vscCommand" JSON key. For example, this configuration will show the Open File dialog when F5 is hit:

{
    "name": "F5 Anything: Open File",
    "type": "f5anything",
    "request": "launch",
    "vscCommand": "workbench.action.files.openFile",
}

To get a command ID:

  1. Find your command in the Ctrl+Shift+P menu
  2. Click the small gear symbol next to it that opens Keyboard Shortcuts
  3. Right click your command and hit Copy Command ID
  4. Paste it into your launch configuration as the "vscCommand" value

If "command" and "vscCommand" both exist in a launch configuration they will both be run. When either is the empty string "" it is ignored and does nothing.

Configuration Details

A quick way to add launch configurations is the "Add Configuration..." button on the bottom right of a launch.json. Hit that and start typing "F5 Anything" for a premade configuration:

adding configurations example screenshot

The basic configuration only has the necessary configuration properties ("name", "type", "request", and "command" or "vscCommand"). The full configuration has three additional optional properties that relate to "command":

  • "terminalName" (string, defaults to "F5 Anything"): The name given to the dedicated integrated terminal F5 Anything creates for itself.

  • "terminalIndex" (integer, defaults to -1): The index of the integrated terminal in the VSCode terminal list to send commands to. When -1 or out of range a dedicated terminal is created and used. Note that terminals are 0-indexed in order of creation, not by visual order.

  • "showTerminal" (boolean, defaults to true): Whether or not the terminal an F5 Anything command is sent to is given focus.

So, for example, this launch configuration will send commands to the terminal at index 0 but not switch focus to it:

{
    "name": "Another Example",
    "type": "f5anything",
    "request": "launch",
    "command": "echo Hi",
    "terminalIndex": 0,
    "showTerminal": false
}

When "command" is missing or the empty string and only "vscCommand" is present, then all of "terminalName", "terminalIndex", and "showTerminal" are ignored as they do not apply.

See the example workspace and especially its launch.json for some more launch configuration examples.

Resources

f5anything's People

Contributors

discretegames avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

cwyatt29

f5anything's Issues

"showTerminal": false

Hi
"showTerminal": false seems not working, it will jump to focus the terminal
thanks

Add ability to disable switching to the Debug pane on F5

Pressing F5 automatically switches to the Debug pane, which isn't useful when using F5Anything, and having to switch back to the Files pane every time gets annoying fast. Would be great to be able to disable this behavior, if possible.

request support for an auto option in the terminalIndex

Dear F5Anything developer,

I am writing to request support for an auto option in the terminalIndex configuration attribute. Currently, when this attribute is used to specify a terminal index for a debug configuration, it always opens the same terminal instance, which can cause issues when running multiple debug sessions.

I suggest adding an auto option that automatically selects the next available terminal index for each debug session. This would allow users to run multiple debug sessions simultaneously without having to manually specify a terminal index each time.

Here's an example of how this feature could be used in a debug configuration:

{
    "name": "docker bash",
    "terminalName": "docker bash",
    "type": "f5anything",
    "request": "launch",
    "terminalIndex": "auto",
    "command": "docker exec -it web.webtool.dev /bin/bash"
}

With the auto option, each time a user starts a debug session with this configuration, F5Anything would automatically select the next available terminal index and open a new terminal instance. This would greatly simplify the process of running multiple debug sessions and reduce the chance of conflicts between terminal instances.

Thank you for considering this feature request.

Best regards,

fh32000

Is there a way to F5 an extension command?

I am trying to build a general-purpose work environment where I can pick a single 'run the thing' key for every application (which, in my case, includes a wide variety of tooling).

Rather than an external shell command, my use case would be best fit by calling an internal 'feature contribution' command (in this case, picowgo.upload).

Is there a convenient way that this extension can accommodate that use case that I'm missing? And if not, would you consider adding it? :)

Feature suggestion: Kill existing process if running when F5 is pressed

Currently, pressing F5 with this extension while a process is already running in the terminal will just send the text to it on top of the current process, so the user is required to manually halt the process themselves.
It would be really convenient to be able to just press F5 once and have the previous process be stopped automatically by the extension. Other run types (like Python) already have the option to do this.

Add env variables in configuration

adding the ability to define environment variables.

currently, you could do it by adding a prefix in the command, like:

{
  "command": "APP_ENV=development ./build.sh",
  "name": "Build",
  "request": "launch",
  "type": "f5anything"
}

but, it will be nice if you could define it like this:

{
  "command": "./build.sh",
  "name": "Build",
  "request": "launch",
  "type": "f5anything",
  "env": {
     "APP_ENV": "development"
  }
}

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.