skip to Main Content

Is there a one-click solution to stop the currently running command in the terminal and run it again?

Currently, I have to go to terminal -> ctrl+c to halt execution -> run the command again.

Suppose npm run dev is running; then it should stop and run it again after hitting some shortcut. If the single command is not possible, then I can also batch multiple commands in a single shortcut using Commands extension.

2

Answers


  1. Chosen as BEST ANSWER

    @Mark answer helped and if someone's using commands extension, you can batch these commands into one:

    settings.json:

    "commands.commands": {
        "Restart Terminal": {
          "sequence": [
            {
              "command": "workbench.action.terminal.sendSequence",
              "args": {
                "text": "u0003u000D" // you may not need the 'Y'
                // I also have "text": "u001b[5c"   // Ctrl+C in my notes
              }
            },
            {
              "command": "workbench.action.terminal.sendSequence",
              "args": { "text": "u001b[Au000D" } // uparrow and enter
            }
          ],
          "icon": "debug-restart",
          "statusBar": {
            "alignment": "left",
            "text": "RestartTerminal",
            "priority": -4
          }
        }
      }
    
    

    enter image description here


  2. Perhaps this combination of commands – I don’t know the extension syntax you use:

    {
      "command": "workbench.action.terminal.sendSequence",
      "args": {
        "text": "u0003Yu000D"   // you may not need the 'Y'
           // I also have "text": "u001b[5c"   // Ctrl+C in my notes
      }  
    },
    
    {
      "command": "workbench.action.terminal.sendSequence",
      "args": {"text": "u001b[Au000D"},   // uparrow and enter
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search