skip to Main Content

I’m wondering if anyone knows a command or hack to close all OTHER terminals besides the actively focused/selected one?

kill others

Kind of like the Close Others command for open file editors:
close other file editors

2

Answers


  1. I don’t think this is a thing. To substantiate, at the time of this writing (VS Code 1.84):

    • searching "terminal kill" in the command palette doesn’t show such a command
    • triggering autocompletion in keybindings with "terminal.kill" in keybindings.json doesn’t show such a command
    • searching "terminal.kill" in the VS Code source code yields nothing more than can be found in command suggestions in keybindings.json
    • googling "github vscode issues kill all but active terminal" yields nothing in the first page of results
    • searching is:open is:issue label:terminal label:feature-request kill in the issues tab yields nothing

    I’d suggest that you raise a feature-request issue ticket. If you do, please comment here with a link to it or edit the link into this question post.

    If/when you raise an issue ticket, be aware that there are nuances- terminals aren’t constrained to tabs in the Terminal Panel- they can be moved into the editor area as editor tabs as well. There’ll probably need to be some design discussion surrounding that.

    Login or Signup to reply.
  2. I made an extension to add such a command to the terminal tabs’ context menu:

    Close other Terminals

    Close other Terminals extension demo

    Let me know if it works for you.

    It works for multiple terminal tab selections too.

    It closes all the other editors other than the one(s) that are selected when you right-click on one of those. You can right-click on any terminal tab – which may or may not be the currently active terminal.

    You can use the Close other Terminals command from the Command Palette.

    And you can create a keybinding to run the command (in your keybindings.json) like this:

    {
      "key": "alt+k",
      "command": "close-other-terminals.close",
      
      "when": "terminalFocus"   // omit this to have it work in an editor
      // see below to use terminalFocus when clause 
    }
    

    If you want that when clause, make sure to add close-other-terminals.close to the following setting:

    Terminal > Integrated: Commands to Skip Shell
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search