「2022年」windows下开发环境简单配置-基础

前言

windows下,开发相关的软件目前可以通过scoop配置

1. 安装powershell 7

微软官方文档,推荐通过.msi文件的形式安装

2. 安装 Windows terminal

微软官方文档

不建议通过微软商店下载。

Github仓库链接->Windows Terminal

可能会用到的软件集成->Recommended content: WSL…

3. 安装scoop

windows下类似pacmanbrew的软件包管理器

Scoop 官网

软件包的默认安装目录为 $USERS/scoop

安装

先配置系统代理后再安装

get.scoop.sh | iex

使用国内镜像安装*(可能已经失效)

iwr -useb https://gitee.com/glsnames/scoop-installer/raw/master/bin/install.ps1 | iex

基础命令

brew完全一致!

关于垃圾清理

1
2
3
4
5
6
# 删除所有旧版本非全局软件(并删除软件包缓存)
scoop cleanup -k *
# 删除所有旧版本软件(并删除软件包缓存)
sudo scoop cleanup -gk *
# 清除软件包缓存
scoop cache rm *

代理设置

默认使用系统代理

手动指定代理:

1
scoop config proxy 127.0.0.17890

查看代理方式

1
scoop config proxy

取消代理

1
scoop config rm proxy

*使用国内源

与上一小节互斥,目前采用此方法

官方bucket

类似pacman中的分支概念

1
2
3
4
5
6
7
8
9
10
scoop bucket add main 
scoop bucket add extras
scoop bucket add versions
scoop bucket add nirsoft
scoop bucket add php
scoop bucket add nerd-fonts
scoop bucket add nonportable
scoop bucket add java
scoop bucket add games
scoop bucket add jetbrains

国内镜像仓库

参考 包管理 - scoop–Captain’s Geek-Island

1
2
3
4
5
6
7
8
9
scoop bucket add main https://codechina.csdn.net/mirrors/ScoopInstaller/Main.git
scoop bucket add extras https://codechina.csdn.net/mirrors/lukesampson/scoop-extras.git
scoop bucket add nonportable https://codechina.csdn.net/mirrors/TheRandomLabs/scoop-nonportable
scoop bucket add nirsoft https://codechina.csdn.net/mirrors/kodybrown/scoop-nirsoft.git
scoop bucket add nerd-fonts https://codechina.csdn.net/mirrors/matthewjberger/scoop-nerd-fonts.git
scoop bucket add java https://codechina.csdn.net/mirrors/ScoopInstaller/Java.git
scoop bucket add versions https://codechina.csdn.net/mirrors/ScoopInstaller/Versions.git
scoop bucket add games https://codechina.csdn.net/mirrors/Calinou/scoop-games.git
scoop bucket add dorado https://gitee.com/chawyehsu/dorado

删除bucket

1
scoop bucket rm main

安装aria2加速

1
scoop install aria2

配置

1
2
3
scoop config aria2-split 16
scoop config aria2-max-connection-per-server 16
scoop config aria2-min-split-size 1M

关闭命令行警告

1
scoop config aria2-warning-enabled false

进阶使用

进阶使用参考 Scoop - 最好用的 Windows 包管理器 - P3TERX

4. 安装gsudo

类似sudo,用户权限提升

1
scoop install gsudo

5.安装oh-my-posh*

!!!启动速度太慢,已经弃用

万万没想到作者用Go写的。。。

安装字体

全部nerd fonts : Nerd Fonts官网

1
scoop install Meslo-NF-Mono

安装

1
scoop install oh-my-posh

配置主题

参考 Oh My Posh:全平台终端提示符个性化工具–少数派

主题文件夹在 ~\scoop\apps\oh-my-posh\current\themes\

目前选择的是powerlevel10k_lean.omp.json

应用配置

在配置文件中加入以下语句

1
oh-my-posh --init --shell pwsh --config “~\scoop\apps\oh-my-posh\current\themes\powerlevel10k_lean.omp.json” | Invoke-Expression

配置文件的位置,通过 echo $profile查看

若不存在,则新建一个

目前位置为 C:\Users\lhy\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

6.其他软件安装

git

1
scoop install git

winfetch

类似neofetch

1
scoop install winfetch

posh-git*

鸡肋,弃用

自动补全git

1
scoop install posh-git

在配置文件中添加

$env:POSH_GIT_ENABLED = $true开启功能

zlocation

快速跳转,类似zshZ插件

1
scoop install zlocation

psreadline

补全功能

1
scoop install psreadline

配置

首先 notepad $PROFILE

编辑配置文件

该配置抄的 给 PowerShell 带来 zsh 的体验-hez2010

1
2
3
4
5
6
7
Set-PSReadLineOption -PredictionSource History # 设置预测文本来源为历史记录

Set-PSReadlineKeyHandler -Key Tab -Function Complete # 设置 Tab 键补全
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete # 设置 Ctrl+d 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo # 设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward # 设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward # 设置向下键为前向搜索历史纪录

coreutils

A collection of GNU utilities such as bash, make, gawk and grep

1
scoop install coreutils

具体包括:

1
2
3
4
5
'basename'. 'cat'. 'chmod'. 'comm'. 'cp'. 'cut'. 'date'. 'dirname'. 'echo'.
'env'. 'expr'. 'false'. 'fold'. 'head'. 'id'. 'install'. 'join'. 'ln'.
'ls'. 'md5sum'. 'mkdir'. 'msysmnt'. 'mv'. 'od'. 'paste'.'printf'. 'ps'.
'pwd'. 'rm'. 'rmdir'. 'sleep'. 'sort'. 'split'. 'stty'.
'tail'. 'tee'. 'touch'. 'tr'. 'true'. 'uname'. 'uniq'. 'wc'.

unxutils

和coreutils会有重复的

GNU utilities for Win32.

1
scoop install unxutils

lazygit

gitCLI管理软件,很好用

1
scoop install lazygit