注意:本文所有操作都在 git bash terminal 运行。最贴近 Linux 或 macOS 体验的终端!
替换 PS、cmd 为 git bash - 这是第一步 # 体验 +50%
PS cmd 使用体验差,字体太挫,更换字体难如登天。
安装 git 即可,因为 git 自带 git-bash。然后 VSCode 设置默认 terminal 为 git bash,从此可以通过 vscode 设置 git bash 字体。
Git for Windows provides a BASH emulation used to run Git from the command line. *NIX users should feel right at home, as the BASH emulation behaves just like the "git" command in LINUX and UNIX environments.
alias # 体验 +30%
生产力巨大提升
~/.bash_profile
alias p='cd -'
alias gst="git status"
alias st="git status"
alias gp="git push"
alias gl="git pull"
alias gcam="gaa && git commit -am"
alias gcmsg="git commit -m"
alias gco="git checkout"
alias gaa="git add -A"
alias gcm="git checkout master"
alias gd="git diff"
alias dev="bun run dev"
alias b="bun run build"
alias t="bun run test"
alias c="code ."
alias md='mkdir -p'
alias temp='cd /f/temp'
记得重启 bash。或者 source ~/.bash_profile .
安装 nvm
浏览器搜索即可没难点不介绍。
安装 bun # 体验 +10%
若官方方式安装失败,可以尝试:
npm i -g bun
若报错:
npm ERR! Failed to find package "@oven/bun-windows-x64-baseline". You may have used the "--no-optional" flag when running "npm install".
是因为你修改了 npm registry。以下命令可以查看当前设置的 registry:
npm config get registry
修改后重试安装 bun 即可。
npm config set registry https://registry.npmjs.org
安装 starship # 体验 +10%
用 choco 或 scoop 安装过程太长,而且安装失败概率太大,choco 安装的 startship 只能 cmd 和 PS 用。
curl -sS https://starship.rs/install.sh | sh
curl 为 git bash 自带。这是一个技巧互联网或官方都没有提及,但出乎意料安装速度快成功率高。
配置 starship
starship.rs
mkdir -p ~/.config && touch ~/.config/starship.toml
如果 starship terminal 出现乱码(而你又不想安装 nerd font 系列,Windows 安装字体也是一绝 🤣),可以修改成 Windows 支持的 emoji:
# ~/.config/starship.toml
[git_branch]
symbol = '🌱 '
[nodejs]
format = 'via [Node.js $version](bold green) '
Tips:win + . 可以唤起 emoji 键盘。Windows emoji keyboard shortcut
效果
on 🌱 feat/dev-model-reasoning [!+⇕] via Node.js v16.20.2
Windows 常用命令
clip 等同 macOS pbcopy
Example: ❯ clip < ~/.ssh/id_ed25519.pub
原文