♟️

Windows 环境配置

date
slug
status
tags
Windows
summary
type
Property
Feb 26, 2021 10:46 AM

包管理工具

包管理器(package manager)是开发人员常用的生产力工具。

Scoop 的安装

Scoop 由澳洲程序员Luke Sampson于2015年创建,其特色之一就是其安装管理不依赖“管理员权限”,这对使用有权限限制的公共计算机的使用者是一大利好。
其的安装步骤如下:
步骤 1:在 PowerShell 中打开远程权限
Set-ExecutionPolicy RemoteSigned -scope CurrentUser;
步骤 2:自定义 Scoop 安装目录
如果跳过该步骤, Scoop 将默认把所有用户安装的 App 和 Scoop 本身安装: C:\Users\user_name\scoop
$env:SCOOP='自定义目录' [Environment]::SetEnvironmentVariable('SCOOP', $env:SCOOP, 'User')
步骤 3:下载并安装 Scoop
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
步骤 4:安装包(主要是命令行程序):
scoop install <app_name> scoop install sudo

Scoop 的使用(加载扩展库)

步骤 1:安装 Aria2 来加速下载
scoop install aria2 # 关闭加速 # scoop config aria2-enabled false
步骤 2:安装 Git 来添加新仓库
scoop install git
步骤3:添加源
scoop bucket add extras # 添加官方维护的extras库(含大量GUI程序) scoop bucket add jetbrains scoop bucket add nerd-fonts scoop bucket add scoopet https://ghproxy.com/https://github.com/sohaha/scoopet scoop update
更换国内源
git -C "$env:SCOOP\buckets\main" remote set-url origin https://ghproxy.com/https://github.com/ScoopInstaller/Main.git git -C "$env:SCOOP\buckets\extras" remote set-url origin https://ghproxy.com/https://github.com/lukesampson/scoop-extras.git git -C "$env:SCOOP\buckets\nerd-fonts" remote set-url origin https://ghproxy.com/https://github.com/lukesampson/scoop-extras.git

Scoop 日常安装应用

scoop install sudo scoop install jetbrains-toolbox scoop install vscode scoop install motrix scoop install quicklook scoop install PowerToys sudo scoop install JetBrains-Mono
 

配置 WSL 开发

步骤 1 :启用适用于 Linux 的 Windows 子系统
需要先启用“适用于 Linux 的 Windows 子系统”可选功能,然后才能在 Windows 上安装 Linux 分发。
# 以管理员身份打开 PowerShell 并运行 dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
 
步骤 2 :启用虚拟机功能
# 执行完毕后需要重新启动计算机,以完成 WSL 安装 dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
 
步骤 3 :下载 Linux 内核更新包
 
步骤 4 :安装所选的 Linux 分发
打开 Microsoft Store,并选择你偏好的 Linux 分发版。
notion image
首次启动新安装的 Linux 分发版时,将打开一个控制台窗口,系统会要求你等待一分钟或两分钟,以便文件解压缩并存储到电脑上。 未来的所有启动时间应不到一秒。
 
将分发版版本设置为 WSL 1 或 WSL 2:
# 检查分配给每个已安装的 Linux 分发版的 WSL 版本 wsl --list --verbose # 若要将分发版设置为受某一 WSL 版本支持,请运行: wsl --set-version <distribution name> <versionNumber>
 

安装 Docker Desktop

步骤 1 :下载并安装
前往 Docker 官网下载 Docker Desktop ,下载完成后点击安装包安装,一直下一步即可。
 
步骤 2 :开启 WSL2 模式
安装完成后运行程序,进入配置页面,开启 WSL2 模式:
notion image
同时这个地方也需要设置,选择我们上一步安装的 Ubuntu 系统,然后点击右下方的按钮应用修改:
notion image
 
步骤 3 :Docker Hub 镜像加速
国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。国内很多云服务商都提供了国内加速器服务,例如:
由于镜像服务可能出现宕机,建议同时配置多个镜像。各个镜像站测试结果请到 docker-practice/docker-registry-cn-mirror-test 查看。
 

oh-my-posh & posh-git

步骤 1 :
Install-Module posh-git -Scope CurrentUser Install-Module oh-my-posh -Scope CurrentUser
步骤 2 :
# 编辑文件 $Profile # notepad.exe $Profile # 引入 posh-git Import-Module posh-git # 引入 oh-my-posh Import-Module oh-my-posh # 查看主题:Get-PoshThemes # 设置主题 Set-PoshPrompt -Theme material # 每次回溯输入历史,光标定位于输入内容末尾 Set-PSReadLineOption -HistorySearchCursorMovesToEnd # 设置 Tab 键补全 Set-PSReadLineKeyHandler -Key "Tab" -Function MenuComplete # 设置 Ctrl+z 为撤销 Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo # 设置向上键为后向搜索历史记录 Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward # 设置向下键为前向搜索历史纪录 Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
 

Windows Terminal

 
主题美化
访问 主题网站 可以下载自己喜欢的主题,同时 Terminal Splash 也有大量的主题,这里以后面的网站为例,选择 Miku 主题,点击 copy 获取配置文件需要添加的内容。