Using a shell command as VSCode task variable value

This extension provides a way to launch arbitrary shell commands as a VS Code command:

"tasks": [
    {
        "label": "test_arch",
        "type": "shell",
        "command": "echo",
        "args": [
            "${MYARCH}"
        ],
        "options": {
            "env": {
                "MYARCH": "${input:get_arch}"
            }
        },
        "problemMatcher": []
    },
],
"inputs": [
    {
        "id": "get_arch",
        "type": "command",
        "command": "shellCommand.execute",
        "args": {
            "command": "uname -m"
        }
    }
]

One disadvantage I discovered is that you have to press Enter once more when the result of the command is prompted in picker. Aside of this, this is the straightest way to implement what you want, and yet it can be utilized in many similar situations.

Alternatively, you can add pickString input with arch picker or create an extension that adds only single command GetArch.

Leave a Comment