6

I want to run bash script when I hit F5 and see the results in the terminal like I can do with python scripts or whatever. I tried to do that with Bash Debug however it automatically goes to the debug mode and stops at the first step even if I do not put breakpoint. This is the launch configuration I use.

        {
            "type": "bashdb",
            "request": "launch",
            "name": "Run mysql test",
            "cwd": "${workspaceFolder}",
            "program": "/srv/gpf/dba/mysqlslap/run.sh",
            "args": []
        }

1 Answer 1

13

I don't know about running bash in a debug mode (doesn't seem like you need those features based on your example) but you can easily get your script to run as a Task or Build option.

Place this at .vscode/tasks.json of your project dir

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run as Bash Script",
            "type": "shell",
            "command": "/bin/bash ${file}",
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

You can place whatever you want in the "command" parameter.

As you can see, it's of type "kind": "build" so I can hit ctrl+shift+B and this will execute in a terminal.

Note, you can also use the command palette (F1 or ctrl+shift+P) and use Task: Run as Task too.

Source: https://code.visualstudio.com/Docs/editor/tasks

Sign up to request clarification or add additional context in comments.

2 Comments

running in debug means when you run the script and go step by step, set the breakpoints, watch runtime variable values and so on.
@DmitrijKultasev I re-read my answer and I meant no offense! I just mean "it didn't look like you needed breakpoints and the testing features". I will rephrase my answer there

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.