Featured image of post Windows 开发工具链:bun / nvm / gh / jq / ripgrep / Neovim / Git 实战

Windows 开发工具链:bun / nvm / gh / jq / ripgrep / Neovim / Git 实战

Windows 开发者日常工具配置:bun 运行时、nvm + node 多版本、GitHub CLI、jq/ripgrep/uvx 文本三剑客、Neovim + LazyVim、Git 高级用法与 Fork 同步。

一、bun:Node.js 的高性能替代

bun 是 2022 年后崛起的 JavaScript 运行时(Zig 写),比 Node.js 快 3~4 倍,自带包管理器 / TS 编译器 / 测试运行器

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Linux
curl -fsSL https://bun.com/install | bash

cat << 'EOF' >> ~/.zshrc
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
EOF

source ~/.zshrc
bun -v
bun upgrade
1
2
# Windows
powershell -c 'irm bun.sh/install.ps1|iex'

二、nvm + Node 多版本

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Linux
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash

# 写入 .zshrc
cat << 'EOF' >> ~/.zshrc
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
EOF

source ~/.zshrc

nvm ls-remote
nvm install v22.22.3
node -v

三、GitHub CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Linux (Debian)
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
    && sudo mkdir -p -m 755 /etc/apt/keyrings \
    && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
    && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
    && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
    && sudo mkdir -p -m 755 /etc/apt/sources.list.d \
    && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
    && sudo apt update \
    && sudo apt install gh -y

gh --version

# 更新
sudo apt update && sudo apt install gh

# Windows
scoop install gh

授权

1
2
3
4
5
6
git config --global user.name "Your Name"
git config --global user.email "your@email.com"

gh auth login
# Github.com -> HTTPS -> Auth? YES -> Paste an auth token
# 输入 gh pat 创建即可

四、jq + ripgrep + uvx:文本三剑客

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# jq - JSON 处理
apt install jq                 # Linux
scoop install jq jid           # Windows
jq -V

# ripgrep - 替代 grep
apt install ripgrep            # Linux
scoop install ripgrep          # Windows
rg -V

# uvx - Python 工具运行(uv 是新一代 pip)
curl -LsSf https://astral.sh/uv/install.sh | sh
which uvx

# Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
(Get-Command uvx).source

五、Neovim + LazyVim

1
2
3
4
5
# Linux
sudo apt install neovim -y

# Windows
scoop install neovim

LazyVim 需求

  • Neovim >= 0.11.2(需 LuaJIT)
  • Git >= 2.19.0(partial clone)
  • Nerd Font v3.0+(图标,可选)
  • lazygit(可选)
  • tree-sitter-cli + C compiler
  • curl(blink.cmp 引擎)
  • fzf v0.25.1+、ripgrep、fd

安装

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Linux
sudo apt install -y build-essential fzf fd-find lazygit
fzf --version
fdfind -V

mv ~/.config/nvim{,.bak}
git clone https://github.com/LazyVim/starter ~/.config/nvim
rm -rf ~/.config/nvim/.git

echo 'export EDITOR=nvim' >> ~/.zshrc
source ~/.zshrc

# 字体
git clone --depth 1 https://github.com/ryanoasis/nerd-fonts.git ~/workspace/github/nerd-fonts
cd ~/workspace/github/nerd-fonts
./install.sh JetBrainsMono
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Windows
scoop bucket add extras
scoop install lazygit
scoop install fzf fd
npm install -g tree-sitter-cli
winget install --id=BrechtSanders.WinLibs.POSIX.UCRT -e -s winget

Move-Item $env:LOCALAPPDATA\nvim $env:LOCALAPPDATA\nvim.bak
git clone https://github.com/LazyVim/starter $env:LOCALAPPDATA\nvim
Remove-Item $env:LOCALAPPDATA\nvim\.git -Recurse -Force

LazyVim 快捷键

LazyVim 用 which-key.nvim 弹窗展示快捷键。默认:

  • <leader> = <space>
  • <localleader> = \

<space> 即可看到所有以空格开头的快捷键。

六、Git 高级用法

全局忽略

1
git config --global core.excludesFile ~/.gitignore_global

Git LFS

1
2
git lfs install
# Git LFS initialized.

SSH + GitHub

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 1. 生成密钥(~/.ssh/{id_ed25519,id_ed25519.pub})
ssh-keygen -t ed25519 -C "your@email.com"

# 2. 配置 ~/.ssh/config(GitHub 443 端口兜底)
Host github.com
    HostName ssh.github.com
    Port 443
    User git
    IdentityFile ~/.ssh/id_ed25519

# 3. 把公钥配置到 GitHub(Settings -> SSH and GPG keys)
cat ~/.ssh/id_ed25519.pub
# ssh-ed25519 AAAA... your@email.com

# 4. 测试
ssh -Tv git@github.com

# 5. 拉取 fork 项目并跟踪上游
git clone git@github.com:yourname/project.git
cd project
git remote add upstream https://gitlab.com/original/project.git

# 6. 学习分支
git checkout -b study-notes
git add .
git commit -m "feat: 学习笔记 - 渲染管线初始化逻辑说明"

# 7. 同步官方
git fetch upstream
git rebase upstream/master
# 冲突时合并
git add <冲突文件>
git rebase --continue
# 强制推送
git push origin study-notes --force

# 8. master 对齐官方
git checkout master
git pull upstream master
git push origin master

七、Umi-OCR:离线 OCR

1
2
scoop bucket add extras
scoop install extras/umi-ocr-paddle

八、常用命令(PowerShell)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# 打开资源管理器当前位置
ii .

# 查端口的 PID
netstat -ano | findstr "32767"

# 查 PID 的进程
tasklist | findstr "15764"

# 结束进程
taskkill /F /PID 2932
taskkill /f /t /im AxureRP9.exe

# 创建文件
New-Item -Path .\文件名.后缀 -ItemType File
ni 文件名.后缀  # 简化写法

下一步

  • 想把 VSCode / IDEA 用上这些工具,看 2019-04-15《AI 编程工具链》
  • 想用 WezTerm 当主力终端,看 2017-11-15《Windows 终端与 Shell 工具链》

参考资料

  • bun 官方:https://bun.sh
  • nvm 官方:https://github.com/nvm-sh/nvm
  • GitHub CLI:https://cli.github.com
  • ripgrep:https://github.com/BurntSushi/ripgrep
  • uv:https://github.com/astral-sh/uv
  • LazyVim:https://www.lazyvim.org
使用 Hugo 构建
主题 StackJimmy 设计