pucelle / vscode-run-on-save

Run configured shell commands when a file is saved in vscode, and output configured messages on status bar.
https://marketplace.visualstudio.com/items?itemName=pucelle.run-on-save
MIT License
50 stars 11 forks source link

How can i save command output and use it in the next command easily #25

Closed majkinetor closed 1 year ago

majkinetor commented 2 years ago

Lets say I want to do something like this:

{
           {
                "match": "\\\\MyDir\\\\",
                "isAsync": false,
                "cmd": "$DIR = 'MyDir'",
            },
            {
                "match": "\\\\$DIR\\\",
                "isAsync": false,
                "cmd": "some other command"
            },
           ....
}

I.e. in this case I want to specify matching directory once and run N subsequent commands with the same match. In another case I want output of command to use in next one for example to find out git root path I needed to use git rev-parse --show-toplevel and then do some other command in that dir.

Is this possible somehow easily?

pucelle commented 2 years ago

If you are working on windows platform, you may try the "environment variable". Mac OS should have similar functionality.

Otherwise, you mentioned that you want to pass output from one command to the next, this is what a vscode plugin can do, but I don't think it should do. You can try program a simple nodejs or python script to do so, with very few lines of codes, and you can run it conveniently from this vscode plugin.

majkinetor commented 2 years ago

If you are working on windows platform, you may try the "environment variable"

Is this going to work without system env vars (which is wrong). You must execute commands in the same shell for this to work, or export/import env vars between them. System env vars for this are 100% wrong.

You can try program a simple nodejs or python script to do so, with very few lines of codes, and you can run it conveniently from this vscode plugin.

Sure, this was always an option, just wanted to check out here first.