How to run streamlit multi-command in VS Code regardless of default terminal

Viewed 361

I have the Multi-command extension installed on VS Code and use it to launch Streamlit apps using this configuration in settings.json which is run via a keyboard shortcut:

"multiCommand.commands": [
    {
        "command": "multiCommand.streamlitActiveFile",
        "label": "Streamlit: Run Active File",
        "description": "Streamlit run active file in active terminal",
        "sequence": [
            "workbench.action.terminal.focus",
            {
                "command": "workbench.action.terminal.sendSequence",
                "args": {
                    "text": "streamlit run ${relativeFile}\u000D"
                }
            }
        ]
    }
]

This has worked fine thus far while I have been using the standard command prompt on a Windows machine. Now I've changed to using Git Bash as my default terminal, and the command above fails because the relative file path is passed as a Windows path with backslashes, and Git Bash can't parse that:

$ streamlit run visuals\streamlit\time_plot.py
Usage: streamlit run [OPTIONS] TARGET [ARGS]...
Try 'streamlit run --help' for help.

Error: Invalid value: File does not exist: visualsstreamlittime_plot.py

In short, the backslashes are ignored and the path becomes a single file name instead. I'd like some way to be able to launch Streamlit apps using a multi-command via a keyboard shortcut, and I'm open to either of these solutions, or something else I haven't considered:

  • Send a relative file path that can be parsed correctly regardless of which terminal is the default terminal.
  • Launch a Windows command prompt even when Git Bash is the default terminal, and activate the Streamlit app there.
  • Change the working directory to the directory containing the streamlit file (again regardless of which terminal is the default terminal) and launch the file there without having to give a path.
0 Answers
Related