web-dev-qa-db-fra.com

Comment changer le terminal intégré dans Visual Studio Code ou VSCode

Je veux changer le terminal intégré en CMDER j'utilise Vscode sur Windows 8.1 J'ai vérifié la doc et le fichier de préférences, mais je me suis trompé, donc à partir des lignes suivantes, quelle ligne le changera

// Terminal externe

// Customizes which terminal to run on Windows.
"terminal.external.windowsExec": "%COMSPEC%",

// Customizes which terminal application to run on OS X.
"terminal.external.osxExec": "Terminal.app",

// Customizes which terminal to run on Linux.
"terminal.external.linuxExec": "xterm",

// Terminal intégré

// The path of the Shell that the terminal uses on Linux.
"terminal.integrated.Shell.linux": "sh",

// The command line arguments to use when on the Linux terminal.
"terminal.integrated.shellArgs.linux": [],

// The path of the Shell that the terminal uses on OS X.
"terminal.integrated.Shell.osx": "sh",

// The command line arguments to use when on the OS X terminal.
"terminal.integrated.shellArgs.osx": [],

// The path of the Shell that the terminal uses on Windows. When using shells shipped with Windows (cmd, PowerShell or Bash on Ubuntu), prefer C:\Windows\sysnative over C:\Windows\System32 to use the 64-bit versions.
"terminal.integrated.Shell.windows": "C:\\Windows\\system32\\cmd.exe",

// The command line arguments to use when on the Windows terminal.
"terminal.integrated.shellArgs.windows": [],

// Controls the font family of the terminal, this defaults to editor.fontFamily's value.
"terminal.integrated.fontFamily": "",

// Controls whether font ligatures are enabled in the terminal.
"terminal.integrated.fontLigatures": false,

// Controls the font size in pixels of the terminal, this defaults to editor.fontSize's value.
"terminal.integrated.fontSize": 0,

// Controls the line height of the terminal, this number is multipled by the terminal font size to get the actual line-height in pixels.
"terminal.integrated.lineHeight": 1.2,

// Controls whether the terminal cursor blinks.
"terminal.integrated.cursorBlinking": false,

// Controls whether locale variables are set at startup of the terminal, this defaults to true on OS X, false on other platforms.
"terminal.integrated.setLocaleVariables": false,

// A set of command IDs whose keybindings will not be sent to the Shell and instead always be handled by Code. This allows the use of keybindings that would normally be consumed by the Shell to act the same as when the terminal is not focused, for example ctrl+p to launch Quick Open.
"terminal.integrated.commandsToSkipShell": [
    "editor.action.toggleTabFocusMode",
    "workbench.action.debug.continue",
    "workbench.action.debug.restart",
    "workbench.action.debug.run",
    "workbench.action.debug.start",
    "workbench.action.debug.stop",
    "workbench.action.quickOpen",
    "workbench.action.showCommands",
    "workbench.action.terminal.clear",
    "workbench.action.terminal.copySelection",
    "workbench.action.terminal.focus",
    "workbench.action.terminal.focusNext",
    "workbench.action.terminal.focusPrevious",
    "workbench.action.terminal.kill",
    "workbench.action.terminal.new",
    "workbench.action.terminal.paste",
    "workbench.action.terminal.runSelectedText",
    "workbench.action.terminal.scrollDown",
    "workbench.action.terminal.scrollDownPage",
    "workbench.action.terminal.scrollToBottom",
    "workbench.action.terminal.scrollToTop",
    "workbench.action.terminal.scrollUp",
    "workbench.action.terminal.scrollUpPage",
    "workbench.action.terminal.toggleTerminal"
],
47
Maddy plus plus

Pour changer le terminal intégré sous Windows, il vous suffit de changer la ligne terminal.integrated.Shell.windows:

  1. Ouvrez les paramètres utilisateur VS (Préférences> Paramètres utilisateur). Cela ouvrira deux documents côte à côte.
  2. Ajoutez un nouveau paramètre "terminal.integrated.Shell.windows": "C:\\Bin\\Cmder\\Cmder.exe" au document des paramètres de l'utilisateur situé à droite s'il ne s'y trouve pas déjà. C'est pour que vous n'éditez pas directement le paramètre par défaut, mais que vous y ajoutiez.
  3. Enregistrez le fichier de paramètres utilisateur.

Vous pouvez ensuite y accéder avec les clés Ctrl+backtick par défaut.

39
mbernardeau

Il est possible que cela fonctionne dans VS Code et que le terminal Cmder soit intégré (ne s'ouvre pas).

Faire cela:

  1. Créez une variable d’environnement "CMDER_ROOT" pointant vers votre répertoire Cmder.
  2. Dans (Préférences> Paramètres utilisateur) dans VS Code, ajoutez les paramètres suivants:

"terminal.integrated.Shell.windows": "cmd.exe"

"terminal.integrated.shellArgs.windows": ["/k", "%CMDER_ROOT%\\vendor\\init.bat"]

37
khernand

Je sais que c'est en retard, mais vous pouvez le faire rapidement en tapant simplement Ctrl + Maj + p puis taper par défaut, une option indiquant

Terminal: Sélectionnez Shell par défaut

, il affichera alors tous les terminaux à votre disposition.

21
etp23

De Documents officiels

Pour configurer correctement votre shell sous Windows, il vous suffit de localiser le bon exécutable et de mettre à jour le paramètre. Vous trouverez ci-dessous une liste des exécutables Shell courants et leurs emplacements par défaut.

Il y a aussi la commande de commodité Sélectionnez Shell par défaut accessible via la palette de commandes qui permet de détecter et de définir ceci pour vous.

Pour pouvoir ouvrir une palette de commandes à l’aide de ctrl+shift+p, utilisez la commande . Sélectionnez Shell par défaut , puis affichez toutes les interfaces de ligne de commande disponibles. quel que soit votre choix, le code VS le définit comme terminal intégré par défaut pour vous automatiquement.

Si vous souhaitez le définir manuellement, recherchez l'emplacement de l'exécutable de votre cli et ouvrez les paramètres utilisateur de vscode (ctrl+,), puis définissez

"terminal.integrated.Shell.windows":"path/to/executable.exe"

Exemple pour gitbash sur windows7:

"terminal.integrated.Shell.windows":"C:\\Users\\stldev03\\AppData\\Local\\Programs\\Git\\bin\\bash.exe",

J'ai réussi avec les paramètres> Terminal> Intégré> Shell: Linux

à partir de là, j'ai modifié le chemin du shell pour qu'il soit /bin/zsh par défaut /bin/bash

  • il existe également des options pour OSX et Windows

screencap of vs settings view

1
mcgraw

La manière officielle est décrite dans la documentation du code VS , qui est similaire à khernands answer.

Si vous ne souhaitez pas définir CMDER_ROOT en tant que variable d'environnement globale, vous pouvez le faire dans ce fichier de traitement par lots. De plus, la cd dans le répertoire de travail actuel à la fin résolue un problème de chemin pour moi.

Cependant, j'ai rencontré une limitation avec CMDER comme terminal intégré par défaut: cela ne fonctionne pas si vous souhaitez exécuter des tâches via Command Pallette -> commande "Run task" de VS Code UI (comme "Run Build Task") . Plus sur ceci ici et ici .

Dans ce cas, il suffit de définir la Shell pour la tâche spécifique:

"tasks": [
    {
        "type": "TypeScript",
        "tsconfig": "tsconfig.json",
        "problemMatcher": [
            "$tsc"
        ],
        "options": {
            "Shell": {
                "executable": "cmd.exe",
                "args": [
                    "/d", "/c"
                ]
            }
        }
    }
]
0
ford04