天天看點

Windows Terminal 配置檔案

https://github.com/microsoft/terminal/releases

如果考慮離線安裝,建議下載下傳 PreinstallKit 包,安裝檔案是 *.msixbundle 檔案。

Microsoft.WindowsTerminal_1.2.2381.0_8wekyb3d8bbwe.msixbundle_Windows10_PreinstallKit.zip

教程:https://docs.microsoft.com/zh-cn/windows/terminal/

配置檔案位置:%appdata%\..\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json

離線安裝

1. 需要系統安裝了 Desktop Bridge VC++ v14 Redistributable Package

https://www.microsoft.com/en-us/download/details.aspx?id=53175

2. 解壓 PreinstallKit.zip

3. 進入 PreinstallKit 目錄,以管理者身份啟動 CMD,運作下面 Dism 指令

dism /online /add-provisionedappxpackage /packagepath:1d5af5799bc14cbbb44f525e79581d2b.msixbundle /licensepath=1d5af5799bc14cbbb44f525e79581d2b_License1.xml /customdatapath:MPAP_1d5af5799bc14cbbb44f525e79581d2b_001.provxml

其中 /packagepath,/licensepath 和 /customdatapath 都可以使用絕對路徑。

安裝成功後,在“開始”菜單中,就可以找到 Windows Terminal 程式。

如果不想使用自定義目錄,直接将 PreinstallKit 包中的 .msibundle 和對應的 msix 解壓到一個自定義的檔案夾,

運作其中的 wt.exe 或者 WindowsTerminal.exe

{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "defaultProfile": "{f323ab3c-9641-4904-a3a6-dc4e4992b6ae}",
    "copyOnSelect": false,
    "copyFormatting": false,
    // "theme": "light",
    "profiles": {
        "defaults": {
            "acrylicOpacity": 0.7,
            // "colorScheme": "Frost",
            // "cursorColor": "#000000",
            "fontFace": "Cascadia Code PL",
            "useAcrylic": true
        },
        "list": [
            {
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false
            },
            {
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "指令提示符",
                "commandline": "cmd.exe",
                "hidden": false
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{f323ab3c-9641-4904-a3a6-dc4e4992b6ae}",
                "name": "Git Bash",
                "commandline": "%programfiles%\\Git\\bin\\bash.exe --login",
                "hidden": false,
                "closeOnExit": true,
                "fontFace": "Cascadia Code PL",
                "icon": "%programfiles%\\Microsoft VS Code\\resources\\app\\extensions\\git\\resources\\icons\\git.png"
            }
        ]
    },
    "schemes": [
        {
            "name": "Frost",
            "background": "#FFFFFF",
            "black": "#3C5712",
            "blue": "#17b2ff",
            "brightBlack": "#749B36",
            "brightBlue": "#27B2F6",
            "brightCyan": "#13A8C0",
            "brightGreen": "#89AF50",
            "brightPurple": "#F2A20A",
            "brightRed": "#F49B36",
            "brightWhite": "#741274",
            "brightYellow": "#991070",
            "cyan": "#3C96A6",
            "foreground": "#000000",
            "green": "#6AAE08",
            "purple": "#991070",
            "red": "#8D0C0C",
            "white": "#6E386E",
            "yellow": "#991070"
        }
    ],
    "keybindings": [
        {
            "command": {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        {
            "command": {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        }
    ]
}      

注冊右鍵菜單(需要用管理者身份運作)

Microsoft.Terminal.Here.bat

:: install or uninstall windows terminal here
:: written by m2nlight
@echo off
setlocal enabledelayedexpansion
set regkey=HKCR\Directory\Background\shell\wt_shell
set regkey2=HKCR\Directory\shell\wt_shell
set exe="%userprofile%\AppData\Local\Microsoft\WindowsApps\wt.exe"
set icon=%exe%
if exist %exe% (
    set regkey2=
    set icon=
)
set title=Windows Terminal
set cmdText=Open in Windows Terminal
set cmdLine=\"%exe%\"
:: check UAC
set getadminfile="%temp%\getadmin.vbs"
echo %title%
echo ============================
echo Starting, please allow UAC window...
>nul 2>nul "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\SYSTEM"
if %ERRORLEVEL% equ 0 (
    echo goto start
    goto :start
) else (
    if %ERRORLEVEL% equ 2 (
        goto :pathErr
    ) else (
        goto :getUAC
    )
)
:pathErr
echo.
echo Please open "%~n0%~x0" in explorer.exe
echo.
echo Press any key to explore the folder...
pause>nul
start "" "%SYSTEMROOT%\system32\explorer.exe" /select,"%~f0"
goto :eof
:getUAC
echo Set sh = CreateObject^("Shell.Application"^) > %getadminfile%
echo sh.ShellExecute "%~f0", "", "", "runas", 1 >> %getadminfile%
ping 127.1 -n 1 >nul
"%SYSTEMROOT%\system32\cscript.exe" %getadminfile% >nul 2>nul
goto :eof
:start
if exist %getadminfile% ( del %getadminfile% )
cls
rem UAC code end
echo %title%
echo ============================
:: check is installed
reg query "%regkey%" >nul 2>nul
if errorlevel 1 goto :install
goto :uninstall
:install
:: check wt.exe is existed
if not exist "%exe%" (
    echo Please install %title%, first!
    pause>nul
    goto :eof
) else (
    :: find WindowsTerminal.exe and set icon
    if "%icon%"=="" (
        for /f %%i in ('dir /b /w "%programfiles%\WindowsApps\Microsoft.WindowsTerminal_*"') do (
            set wtfull=%programfiles%\WindowsApps\%%~i\WindowsTerminal.exe
            if exist "!wtfull!" (
                set icon=!wtfull!
                goto :breakfor
            )
        )
    )
    :breakfor
    if not "%regkey%"=="" call :regadd "%regkey%"
    if not "%regkey2%"=="" call :regadd "%regkey2%"
    echo %cmdText% is installed
)
goto :end

:regadd
reg add "%~1" /ve /t REG_SZ /d "%cmdText%" /f >nul 2>nul
if not "%icon%"=="" reg add "%~1" /v Icon /t REG_SZ /d "%icon%" /f >nul 2>nul
reg add "%~1\command" /ve /t REG_SZ /d "%cmdLine%" /f >nul 2>nul
goto :eof

:uninstall
set /p ok=Uninstall %title% (y/N)?^ 
if /i "%ok%"=="y" (
    if not "%regkey%"=="" reg delete "%regkey%" /f >nul 2>nul
    if not "%regkey2%"=="" reg delete "%regkey2%" /f >nul 2>nul
    echo %cmdText% is uninstalled
) else (
    goto :eof
)
goto :end
:end
timeout /t 5      

繼續閱讀