Windows Terminal

新的 Windows 终端和原始 Windows 控制台主机 —— 都在同一个地方!(The new Windows Terminal, and the original Windows console host -- all in the same place!)

欢迎!

此存储库包含以下源代码:

  • Windows 终端
  • Windows 控制台主机(conhost.exe)
  • 两个项目之间共享的组件
  • ColorTool
  • 示例项目,说明如何使用 Windows 控制台 API

其他相关的存储库包括:

终端和控制台概述

在深入了解代码之前,请花几分钟时间查看下面的概述:

Windows 终端

Windows Terminal 是一个面向命令行用户的全新、现代、功能丰富、高效的终端应用程序。它包括 Windows 命令行社区最常请求的许多功能,包括对选项卡、富文本、全球化、可配置性、主题和样式等的支持。

终端还需要满足我们的目标和措施,以确保它保持快速、高效,并且不会消耗大量的内存或电力。

Windows 控制台主机

Windows 控制台主机 conhost.exe 是 Windows 的原始命令行用户体验。它实现了Windows 的命令行基础结构,并负责托管 Windows 控制台 API,输入引擎,呈现引擎和用户首选项。此存储库中的控制台主机代码是构建 Windows 本身中的 conhost.exe 的实际源。

控制台的主要目标是与现有控制台子系统应用程序保持向后兼容。

自2014年获得 Windows 命令行的所有权以来,该团队已向控制台添加了几项新功能,包括窗口透明度,基于行的选择,支持 ANSI/Virtual Terminal sequences24位颜色Pseudoconsole ("ConPTY"),和更多。

但是,由于 Console 的主要目标是保持向后兼容性,因此我们无法添加社区一直要求的许多功能,以及我们过去几年一直希望添加的功能 —— 比如标签!

这些限制促使我们创建了新的 Windows 终端。

共享组件

在对控制台进行大修时,我们对代码库进行了大规模的现代化改造。我们将逻辑实体完全分离为模块和类,引入了一些关键的可扩展点,用更安全、更高效的 STL 容器替换了几个旧的、自行开发的集合和容器,并通过使用 Microsoft 的 WIL 头库使代码更简单、更安全。

这项大修工作导致创建了几个关键组件,这些组件对 Windows 上的任何终端实现都很有用,包括一个新的基于 DirectWrite 的文本布局和渲染引擎,一个能够存储 UTF-16 和 UTF-8 的文本缓冲区,以及 VT parser/emitter(解析器/发射器)。

建立一个新的终端

当我们开始构建新的终端应用程序时,我们探索并评估了几种方法和技术栈。 我们最终决定通过坚持使用 C++ 并共享上述现代化组件,将它们置于现代 Windows 应用程序平台和 UI 框架之上来最好地实现我们的目标。

此外,我们意识到这将允许我们将终端的渲染器和输入堆栈构建为可重用的 Windows UI 控件,其他人可以将其合并到他们的应用程序中。

常问问题

我在哪里可以下载 Windows 终端?

目前还没有可下载的二进制文件。

Windows 终端还处于非常早期的 alpha 阶段,还没有为公众准备好。如果您想尽早介入,可以自己尝试从源代码构建它。

否则,您需要等到6月中旬,那时官方才能发布预览版。

我建立并运行了新的终端,但我只是得到一个空白的窗口应用程序!

确保您正在构建计算机的体系结构。如果您的电脑安装的是 64位 Windows,请将您的解决方案平台更改为 x64。

要检查您的操作系统架构,请转到设置 ->系统 ->关于(或 Win + X ->系统),然后在设备规格下检查系统类型。

我建造并运行了新的终端,但它看起来就像旧的控制台!这是怎么了?

首先,确保在 Visual Studio 中构建和部署 CascadiaPackage,而不是 Host.EXE。 OpenConsole.exe 只是 conhost.exe,你知道和喜欢的旧控制台。 opencon.cmd 将启动 openconsole.exe,不幸的是,openterm.cmd 目前已被破坏。

其次,尝试按 Ctrl + T.默认情况下,只有一个选项卡时,隐藏选项卡。将来,UI 会有很大的不同,但是现在,默认值应该看起来像控制台的默认值。

我试过运行 WindowsTerminal.exe 它崩溃了!

不要试图将其解包运行。确保从 Visual Studio 构建和部署 CascadiaPackage,并运行 Windows Terminal(Dev Build)应用程序。

确保您使用的是正确版本的 Windows。您需要使用 Insider 的版本,或等待 1903版本,因为 Windows 终端需要最新 Windows 版本的功能。

入门

先决条件

  • 您必须运行 Windows 1903 (build >=10.0.18362.0) 或更高版本才能运行 Windows 终端
  • 从2019年5月起, 此版本只能通过 Windows 内部程序获得。您可以通过设备的系统设置注册和配置内部程序。

调试

要在 VS 中进行调试, 请右键单击 "CascadiaPackage" (从 VS 解决方案资源管理器) 并转到属性, 在 "调试" 菜单中, 将 "应用程序进程" 和 "后台任务进程" 更改为 "仅本机"。

文档

所有文档都位于./doc 文件夹中。如果您想提供文件, 请提交一个拉请求。

Main metrics

Overview
Name With Ownermicrosoft/terminal
Primary LanguageC++
Program languageC# (Language Count: 12)
PlatformWindows
License:MIT License
所有者活动
Created At2017-08-11 18:38:22
Pushed At2025-06-12 01:31:27
Last Commit At
Release Count162
Last Release Namev1.23.11132.0 (Posted on 2025-04-25 12:30:14)
First Release Name1708.14008 (Posted on )
用户参与
Stargazers Count98.6k
Watchers Count1.3k
Fork Count8.6k
Commits Count4.6k
Has Issues Enabled
Issues Count13351
Issue Open Count1606
Pull Requests Count4111
Pull Requests Open Count49
Pull Requests Close Count534
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

terminal-logos

Welcome to the Windows Terminal, Console and Command-Line repo

This repository contains the source code for:

Related repositories include:

Installing and running Windows Terminal

[!NOTE]
Windows Terminal requires Windows 10 2004 (build 19041) or later

Install the Windows Terminal from the Microsoft Store.
This allows you to always be on the latest version when we release new builds
with automatic upgrades.

This is our preferred method.

Other install methods

Via GitHub

For users who are unable to install Windows Terminal from the Microsoft Store,
released builds can be manually downloaded from this repository's Releases
page
.

Download the Microsoft.WindowsTerminal_<versionNumber>.msixbundle file from
the Assets section. To install the app, you can simply double-click on the
.msixbundle file, and the app installer should automatically run. If that
fails for any reason, you can try the following command at a PowerShell prompt:

# NOTE: If you are using PowerShell 7+, please run
# Import-Module Appx -UseWindowsPowerShell
# before using Add-AppxPackage.

Add-AppxPackage Microsoft.WindowsTerminal_<versionNumber>.msixbundle

[!NOTE]
If you install Terminal manually:

  • You may need to install the VC++ v14 Desktop Framework Package.
    This should only be necessary on older builds of Windows 10 and only if you get an error about missing framework packages.
  • Terminal will not auto-update when new builds are released so you will need
    to regularly install the latest Terminal release to receive all the latest
    fixes and improvements!

Via Windows Package Manager CLI (aka winget)

winget users can download and install
the latest Terminal release by installing the Microsoft.WindowsTerminal
package:

winget install --id Microsoft.WindowsTerminal -e

[!NOTE]
Dependency support is available in WinGet version 1.6.2631 or later. To install the Terminal stable release 1.18 or later, please make sure you have the updated version of the WinGet client.

Via Chocolatey (unofficial)

Chocolatey users can download and install the latest
Terminal release by installing the microsoft-windows-terminal package:

choco install microsoft-windows-terminal

To upgrade Windows Terminal using Chocolatey, run the following:

choco upgrade microsoft-windows-terminal

If you have any issues when installing/upgrading the package please go to the
Windows Terminal package
page
and follow the
Chocolatey triage process

Via Scoop (unofficial)

Scoop users can download and install the latest Terminal
release by installing the windows-terminal package:

scoop bucket add extras
scoop install windows-terminal

To update Windows Terminal using Scoop, run the following:

scoop update windows-terminal

If you have any issues when installing/updating the package, please search for
or report the same on the issues
page
of Scoop Extras bucket
repository.


Installing Windows Terminal Canary

Windows Terminal Canary is a nightly build of Windows Terminal. This build has the latest code from our main branch, giving you an opportunity to try features before they make it to Windows Terminal Preview.

Windows Terminal Canary is our least stable offering, so you may discover bugs before we have had a chance to find them.

Windows Terminal Canary is available as an App Installer distribution and a Portable ZIP distribution.

The App Installer distribution supports automatic updates. Due to platform limitations, this installer only works on Windows 11.

The Portable ZIP distribution is a portable application. It will not automatically update and will not automatically check for updates. This portable ZIP distribution works on Windows 10 (19041+) and Windows 11.

Distribution Architecture Link
App Installer x64, arm64, x86 download
Portable ZIP x64 download
Portable ZIP ARM64 download
Portable ZIP x86 download

Learn more about the types of Windows Terminal distributions.


Windows Terminal Roadmap

The plan for the Windows Terminal is described here and
will be updated as the project proceeds.

Project Build Status

Project Build Status
Terminal Terminal Build Status
ColorTool Colortool Build Status

Terminal & Console Overview

Please take a few minutes to review the overview below before diving into the
code:

Windows Terminal

Windows Terminal is a new, modern, feature-rich, productive terminal application
for command-line users. It includes many of the features most frequently
requested by the Windows command-line community including support for tabs, rich
text, globalization, configurability, theming & styling, and more.

The Terminal will also need to meet our goals and measures to ensure it remains
fast and efficient, and doesn't consume vast amounts of memory or power.

The Windows Console Host

The Windows Console host, conhost.exe, is Windows' original command-line user
experience. It also hosts Windows' command-line infrastructure and the Windows
Console API server, input engine, rendering engine, user preferences, etc. The
console host code in this repository is the actual source from which the
conhost.exe in Windows itself is built.

Since taking ownership of the Windows command-line in 2014, the team added
several new features to the Console, including background transparency,
line-based selection, support for ANSI / Virtual Terminal
sequences
, 24-bit
color
,
a Pseudoconsole
("ConPTY")
,
and more.

However, because Windows Console's primary goal is to maintain backward
compatibility, we have been unable to add many of the features the community
(and the team) have been wanting for the last several years including tabs,
unicode text, and emoji.

These limitations led us to create the new Windows Terminal.

You can read more about the evolution of the command-line in general, and the
Windows command-line specifically in this accompanying series of blog
posts

on the Command-Line team's blog.

Shared Components

While overhauling Windows Console, we modernized its codebase considerably,
cleanly separating logical entities into modules and classes, introduced some
key extensibility points, replaced several old, home-grown collections and
containers with safer, more efficient STL
containers
,
and made the code simpler and safer by using Microsoft's Windows Implementation
Libraries - WIL
.

This overhaul resulted in several of Console's key components being available
for re-use in any terminal implementation on Windows. These components include a
new DirectWrite-based text layout and rendering engine, a text buffer capable of
storing both UTF-16 and UTF-8, a VT parser/emitter, and more.

Creating the new Windows Terminal

When we started planning the new Windows Terminal application, we explored and
evaluated several approaches and technology stacks. We ultimately decided that
our goals would be best met by continuing our investment in our C++ codebase,
which would allow us to reuse several of the aforementioned modernized
components in both the existing Console and the new Terminal. Further, we
realized that this would allow us to build much of the Terminal's core itself as
a reusable UI control that others can incorporate into their own applications.

The result of this work is contained within this repo and delivered as the
Windows Terminal application you can download from the Microsoft Store, or
directly from this repo's
releases
.


Resources

For more information about Windows Terminal, you may find some of these
resources useful and interesting:


FAQ

I built and ran the new Terminal, but it looks just like the old console

Cause: You're launching the incorrect solution in Visual Studio.

Solution: Make sure you're building & deploying the CascadiaPackage project in
Visual Studio.

[!NOTE]
OpenConsole.exe is just a locally-built conhost.exe, the classic
Windows Console that hosts Windows' command-line infrastructure. OpenConsole
is used by Windows Terminal to connect to and communicate with command-line
applications (via
ConPty).


Documentation

All project documentation is located at aka.ms/terminal-docs. If you would like
to contribute to the documentation, please submit a pull request on the Windows
Terminal Documentation repo
.


Contributing

We are excited to work alongside you, our amazing community, to build and
enhance Windows Terminal!

BEFORE you start work on a feature/fix, please read & follow our
Contributor's
Guide
to
help avoid any wasted or duplicate effort.

Communicating with the Team

The easiest way to communicate with the team is via GitHub issues.

Please file new issues, feature requests and suggestions, but DO search for
similar open/closed preexisting issues before creating a new issue.

If you would like to ask a question that you feel doesn't warrant an issue
(yet), please reach out to us via Twitter:

Developer Guidance

Prerequisites

Building the Code

This repository uses git
submodules
for some of its
dependencies. To make sure submodules are restored or updated, be sure to run
the following prior to building:

git submodule update --init --recursive

OpenConsole.sln may be built from within Visual Studio or from the command-line
using a set of convenience scripts & tools in the /tools directory:

Building in PowerShell

Import-Module .\tools\OpenConsole.psm1
Set-MsBuildDevEnvironment
Invoke-OpenConsoleBuild

Building in Cmd

.\tools\razzle.cmd
bcz

Running & Debugging

To debug the Windows Terminal in VS, right click on CascadiaPackage (in the
Solution Explorer) and go to properties. In the Debug menu, change "Application
process" and "Background task process" to "Native Only".

You should then be able to build & debug the Terminal project by hitting
F5. Make sure to select either the "x64" or the "x86" platform - the
Terminal doesn't build for "Any Cpu" (because the Terminal is a C++ application,
not a C# one).

👉 You will not be able to launch the Terminal directly by running the
WindowsTerminal.exe. For more details on why, see
#926,
#4043

Coding Guidance

Please review these brief docs below about our coding practices.

👉 If you find something missing from these docs, feel free to contribute to
any of our documentation files anywhere in the repository (or write some new
ones!)

This is a work in progress as we learn what we'll need to provide people in
order to be effective contributors to our project.


Code of Conduct

This project has adopted the Microsoft Open Source Code of
Conduct
. For more information see the Code of Conduct
FAQ
or contact opencode@microsoft.com with any
additional questions or comments.