集成的终端Integrated Terminal

Azure Data StudioAzure Data Studio,可以打开集成的终端中,最初你的工作区的根目录开始。In Azure Data StudioAzure Data Studio, you can open an integrated terminal, initially starting at the root of your workspace. 这会非常方便,因为你无需切换窗口或更改的现有终端来执行一个快速的命令行任务的状态。This can be convenient as you don't have to switch windows or alter the state of an existing terminal to perform a quick command-line task.

若要打开终端:To open the terminal:

  • 使用Ctrl +' 使用反撇号字符的键盘快捷方式。Use the Ctrl+` keyboard shortcut with the backtick character.
  • 使用视图 | 集成终端菜单命令。Use the View | Integrated Terminal menu command.
  • 命令面板(Ctrl + Shift + P),使用视图: 切换集成终端命令。From the Command Palette (Ctrl+Shift+P), use the View:Toggle Integrated Terminal command.

终端

备注

仍可以使用资源管理器中打开外部 shell在命令提示符窗口中打开命令 (在终端中打开Mac 或 Linux 上) 如果您想使用外部Azure Data StudioAzure Data StudioYou can still open an external shell with the Explorer Open in Command Prompt command (Open in Terminal on Mac or Linux) if you prefer to work outside Azure Data StudioAzure Data Studio.

管理多个终端Managing Multiple Terminals

可以创建多个终端打开到不同位置,并在它们之间轻松导航。You can create multiple terminals open to different locations and easily navigate between them. 可以通过点击右上角的加号图标来添加终端实例终端面板,或通过触发Ctrl + Shift +' 命令。Terminal instances can be added by hitting the plus icon on the top-right of the TERMINAL panel or by triggering the Ctrl+Shift+` command. 这将创建另一个条目在下拉列表中,可以使用它们之间进行切换。This creates another entry in the dropdown list that can be used to switch between them.

多个终端

按钮可以通过按回收站删除终端实例。Remove terminal instances by pressing the trash can button.

提示

如果广泛使用多个终端,则可以添加的键绑定focusNextfocusPreviouskill命令中所述键绑定部分它们仅使用键盘导航。If you use multiple terminals extensively, you can add key bindings for the focusNext, focusPrevious and kill commands outlined in the Key Bindings section to allow navigation between them using only the keyboard.

配置Configuration

使用默认值为 shell $SHELL Linux 和 macOS、 Windows 10 上的 PowerShell 和 cmd.exe 在早期版本的 Windows 上。The shell used defaults to $SHELL on Linux and macOS, PowerShell on Windows 10 and cmd.exe on earlier versions of Windows. 可以通过设置手动写这些terminal.integrated.shell.*设置These can be overridden manually by setting terminal.integrated.shell.* in settings. Linux 和 macOS 使用,可以将参数传递给终端 shellterminal.integrated.shellArgs.*设置。Arguments can be passed to the terminal shell on Linux and macOS using the terminal.integrated.shellArgs.* settings.

WindowsWindows

在 Windows 上正确配置你的 shell 是找到正确的可执行文件并进行更新的设置。Correctly configuring your shell on Windows is a matter of locating the right executable and updating the setting. 以下是常用的命令行程序可执行文件及其默认位置的列表:Below are a list of common shell executables and their default locations:

// 64-bit cmd if available, otherwise 32-bit
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe"
// 64-bit PowerShell if available, otherwise 32-bit
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
// Git Bash
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
// Bash on Ubuntu (on Windows)
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"

备注

若要用作集成终端,shell 可执行文件必须是一个控制台应用程序,以便stdin/stdout/stderr可以重定向。To be used as an integrated terminal, the shell executable must be a console application so that stdin/stdout/stderr can be redirected.

提示

使用的权限运行集成终端 shell Azure Data StudioAzure Data StudioThe integrated terminal shell is running with the permissions of Azure Data StudioAzure Data Studio. 如果需要使用提升权限 (管理员) 或不同的权限运行 shell 命令,你可以使用如平台实用程序runas.exe终端中。If you need to run a shell command with elevated (administrator) or different permissions, you can use platform utilities such as runas.exe within a terminal.

Shell 参数Shell arguments

启动时,可以将参数传递到 shell。You can pass arguments to the shell when it is launched.

例如,若要启用作为登录 shell 运行 bash (面授.bash_profile),传入-l(用双引号引起来) 的参数:For example, to enable running bash as a login shell (which runs .bash_profile), pass in the -l argument (with double quotes):

// Linux
"terminal.integrated.shellArgs.linux": ["-l"]

终端的显示设置Terminal Display Settings

使用以下设置,可以自定义集成终端的字体和行高度:You can customize the integrated terminal font and line height with the following settings:

  • terminal.integrated.fontFamily
  • terminal.integrated.fontSize
  • terminal.integrated.lineHeight

终端的键绑定Terminal Key Bindings

视图:切换集成终端命令绑定到Ctrl +' 快速切换入和移出视图集成终端面板。The View: Toggle Integrated Terminal command is bound to Ctrl+` to quickly toggle the integrated terminal panel in and out of view.

以下是在集成终端中快速导航的键盘快捷方式:Below are the keyboard shortcuts to quickly navigate within the integrated terminal:

KeyKey CommandCommand
Ctrl+`Ctrl+` 显示集成的终端Show integrated terminal
Ctrl+Shift+`Ctrl+Shift+` 创建新的终端Create new terminal
Ctrl+UpCtrl+Up 向上滚动Scroll up
Ctrl+DownCtrl+Down 向下滚动Scroll down
Ctrl+PageUpCtrl+PageUp 向上滚动一页Scroll page up
Ctrl+PageDownCtrl+PageDown 向下滚动一页Scroll page down
Ctrl+HomeCtrl+Home 滚动到顶部Scroll to top
Ctrl+EndCtrl+End 滚动到底部Scroll to bottom
Ctrl+KCtrl+K 清除终端Clear the terminal

其他终端命令可用,并且可以绑定到首选的键盘快捷方式。Other terminal commands are available and can be bound to your preferred keyboard shortcuts.

它们分别是:They are:

  • workbench.action.terminal.focus设置用户帐户 :重点放在终端。workbench.action.terminal.focus: Focus the terminal. 这类似于切换,但主要而不是隐藏它,终端,如果可见。This is like toggle but focuses the terminal instead of hiding it, if it is visible.
  • workbench.action.terminal.focusNext设置用户帐户 :主要的下一个终端实例。workbench.action.terminal.focusNext: Focuses the next terminal instance.
  • workbench.action.terminal.focusPrevious设置用户帐户 :主要的上一个终端实例。workbench.action.terminal.focusPrevious: Focuses the previous terminal instance.
  • workbench.action.terminal.kill设置用户帐户 :删除当前终端实例。workbench.action.terminal.kill: Remove the current terminal instance.
  • workbench.action.terminal.runSelectedText设置用户帐户 :在终端实例中运行所选的文本。workbench.action.terminal.runSelectedText: Run the selected text in the terminal instance.
  • workbench.action.terminal.runActiveFile设置用户帐户 :在终端实例中运行活动的文件。workbench.action.terminal.runActiveFile: Run the active file in the terminal instance.

运行选定的文本Run Selected Text

若要使用runSelectedText命令,在编辑器中选择文本并运行该命令终端:在活动的终端中运行选定的文本通过命令控制板(Ctrl + Shift + P)。To use the runSelectedText command, select text in an editor and run the command Terminal: Run Selected Text in Active Terminal via the Command Palette (Ctrl+Shift+P). 终端会尝试运行所选的文本:The terminal attempts to run the selected text:

运行选定的文本

如果在活动编辑器中不选择任何文本,则是在终端中运行光标所在的行。If no text is selected in the active editor, the line that the cursor is on is run in the terminal.

复制和粘贴Copy & Paste

用于复制和粘贴的键盘快捷键遵循平台标准:The keybindings for copy and paste follow platform standards:

  • Linux:Ctrl + Shift + CCtrl + Shift + VLinux: Ctrl+Shift+C and Ctrl+Shift+V
  • Mac:Cmd + CCmd + VMac: Cmd+C and Cmd+V
  • Windows:Ctrl + CCtrl + VWindows: Ctrl+C and Ctrl+V

查找Find

集成终端中具有基本查找功能可与触发Ctrl + FThe Integrated Terminal has basic find functionality that can be triggered with Ctrl+F.

如果你想Ctrl + F若要转到 shell 而不是启动 Linux 和 Windows 上的查找小组件,则需要删除键绑定如下所示:If you want Ctrl+F to go to the shell instead of launching the Find widget on Linux and Windows, you need to remove the keybinding like so:

{ "key": "ctrl+f", "command": "-workbench.action.terminal.focusFindWidget",
                      "when": "terminalFocus" },

重命名终端会话Rename terminal sessions

集成终端会话可以现在重命名使用终端:重命名(workbench.action.terminal.rename) 命令。Integrated Terminal sessions can now be renamed using the Terminal: Rename (workbench.action.terminal.rename) command. 在终端选择下拉列表中显示的新名称。The new name is displayed in the terminal selection drop-down.

强制通过终端的键绑定Forcing key bindings to pass through the terminal

在集成终端焦点时,多个键绑定不会工作,因为键击是传递给和使用的终端本身。While focus is in the integrated terminal, many key bindings won't work because the keystrokes are passed to and consumed by the terminal itself. terminal.integrated.commandsToSkipShell设置可用于避免这一问题。The terminal.integrated.commandsToSkipShell setting can be used to get around this. 它包含其键绑定由 shell 跳过处理并改为处理的命令名称的数组Azure Data StudioAzure Data Studio键绑定系统。It contains an array of command names whose key bindings skip processing by the shell and instead be processed by the Azure Data StudioAzure Data Studio key binding system. 默认情况下,这包括所有终端的键绑定,除了选择几个常用键绑定。By default this includes all terminal key bindings in addition to a select few commonly used key bindings.