%%html
<div id="bash-container">
    <div id="bash-output"></div>
    <textarea id="bash-input" placeholder="Type your commands here"></textarea>
    <button id="run-button">Run</button>
</div>
<script>
    const bashContainer = document.getElementById('bash-container');
    const bashOutput = document.getElementById('bash-output');
    const bashInput = document.getElementById('bash-input');
    const runButton = document.getElementById('run-button');


    runButton.addEventListener('click', () => {
        const command = bashInput.value;
        executeBashCommand(command);
});


function executeBashCommand(command) {
    fetch('/run-bash-command', {
         method: 'POST',
        body: JSON.stringify({ command }),
        headers: {
            'Content-Type': 'application/json',
        },
    })
    .then(response => response.text())
    .then(output => {
        bashOutput.innerHTML = `<pre>${output}</pre>`;
    })
    .catch(error => {
        bashOutput.innerHTML = `<pre>Error: ${error.message}</pre>`;
     });
    }
</script>
#!/bin/bash
# Save this file as run-bash-command.sh
# Make it executable: chmod +x run-bash-command.sh


# Read the command from the request body
read -r -d '' COMMAND
echo "Running command: $COMMAND"


# Execute the command and capture the output
OUTPUT=$(eval "$COMMAND" 2>&1)
echo "$OUTPUT"

#!/bin/bash

Save this file as run-bash-command.sh

Make it executable: chmod +x run-bash-command.sh

Read the command from the request body

read -r -d ‘’ COMMAND echo “Running command: $COMMAND”

Execute the command and capture the output

OUTPUT=$(eval “$COMMAND” 2>&1) echo “$OUTPUT”

Purpose of This

This command will not necessarily run on VSCode, but hypotheitcally, it should allow me to run basic bash commands, such as ls, mkdir, etc.