# 打造 Linux 系统（开发篇）


开发人员专用。涉及 git、npm、nodejs等多个工具。

<!--more-->

## 安装 `zsh`

```bash
sudo apt update && sudo apt upgrade -y && sudo apt install zsh -y
# 设置默认 Shell（注意：此处不可以用 sudo）
chsh -s $(which zsh)
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```

### 插件安装

安装方式：把插件下载到本地的 `~/.oh-my-zsh/custom/plugins` 目录。

```bash
# 命令提示插件 `zsh -autosuggestions`
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 命令语法校验插件 `zsh-syntax-highlighting`
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
```

- `oh-my-zsh` 内置了 `z` 插件。`z` 是一个文件夹快捷跳转插件，对于曾经跳转过的目录，只需要输入最终目标文件夹名称，就可以快速跳转，避免再输入长串路径，提高切换文件夹的效率。
- `oh-my-zsh` 内置了 `extract` 插件。`extract` 用于解压任何压缩文件，不必根据压缩文件的后缀名来记忆压缩软件。

### 启用插件

方式一：修改 `~/.zshrc` 中插件列表为

```bash
plugins=(git zsh-autosuggestions zsh-syntax-highlighting z extract)
```

方式二：`sed` 一键替换

```bash
sed -i '/^plugins=(/,/)/c\plugins=(git zsh-autosuggestions zsh-syntax-highlighting z extract)' ~/.zshrc
```

开启新的 Shell 或执行 `source ~/.zshrc`，就可以开始体验插件。

### 配置主题（可选）

```bash
sudo wget -O $ZSH_CUSTOM/themes/haoomz.zsh-theme https://cdn.haoyep.com/gh/leegical/Blog_img/zsh/haoomz.zsh-theme
```

编辑 `~/.zshrc` 文件，将 `ZSH_THEME` 设为 `haoomz`。当然你也可以设置为其他主题，例如 `lukerandall`、`robbyrussell`。

```bash
# sed 一键替换
sed -i 's/^ZSH_THEME=.*/ZSH_THEME="haoomz"' ~/.zshrc
```

## 安装 `WezTerm`

```bash
curl -fsSL https://apt.fury.io/wez/gpg.key | sudo gpg --yes --dearmor -o /usr/share/keyrings/wezterm-fury.gpg
echo 'deb [signed-by=/usr/share/keyrings/wezterm-fury.gpg] https://apt.fury.io/wez/ * *' | sudo tee /etc/apt/sources.list.d/wezterm.list
sudo chmod 644 /usr/share/keyrings/wezterm-fury.gpg

sudo apt update
sudo apt install wezterm
```

### 推荐一位大佬的[`config`配置](https://github.com/KevinSilvester/wezterm-config)

前提条件，必须安装 `JetBrainsMono Nerd Font` 字体

> [字体安装项目](https://github.com/ryanoasis/nerd-fonts?#font-installation)

```bash
# 安装 `JetBrainsMono Nerd Font`  字体
curl -OL https://github.com/ryanoasis/nerd-fonts/releases/latest/download/JetBrainsMono.tar.xz
# 下载配置
git clone https://github.com/KevinSilvester/wezterm-config.git ~/.config/wezterm
```

**就一点非常重要！！！**
- 在 Windows 和 Linux 系统上
    - SUPER ⇨ Alt
    - SUPER_REV ⇨ Alt + Ctrl
- 所有平台：LEADER ⇨ SUPER_REV + Space

## 工具一键安装

```bash
# javascript 开发环境
sudo apt install -y nodejs npm git 
# pnpm 安装
wget -qO- https://get.pnpm.io/install.sh | sh -
# uv管理工具
curl -LsSf https://astral.sh/uv/install.sh | sh
# nvm版本管理
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash
# bun
curl -fsSL https://bun.com/install | bash
# x-cmd 命令行工具集
eval "$(curl https://get.x-cmd.com)"
```

### 配置 `Git` 的用户信息

```bash
git config --global user.name "xx"
git config --global user.email "xxx@xx.com"
```

### 配置 `npm` 镜像源

```bash
# 临时使用淘宝源安装包
npm install react --registry=https://registry.npmmirror.com
# 全局配置镜像源（永久生效）
npm config set registry https://registry.npmmirror.com
# 查看 npm 镜像源
npm config get registry
```

### 配置 `PNPM` 镜像源

```bash
# 全局配置镜像源（永久生效）
pnpm config set registry https://registry.npmmirror.com
# 查看 npm 镜像源
pnpm config get registry

# 全局bin
pnpm config set global-bin-dir ~/environment/pnpm/bin
# 全局缓存
pnpm config set cache-dir ~/environment/pnpm/cache
# 创建pnpm-state.json文件的目录
pnpm config set state-dir ~/environment/pnpm/state
# 全局安装
pnpm config set global-dir ~/environment/pnpm/global
# 全局仓库路径(类似 .git 仓库)
pnpm config set store-dir ~/environment/pnpm/store
# Node.js 存放位置
pnpm config set pnpm-home ~/environment/pnpm
pnpm config set data-dir ~/environment/pnpm/data

# 启用 `Shell` 自动补全（以 Zsh 为例）
pnpm completion zsh >> ~/.zshrc
# Bash 用户：pnpm completion bash >> ~/.bashrc
# Fish 用户：pnpm completion fish > ~/.config/fish/completions/pnpm.fish

# `pnpm` 存储路径可能积累未使用的依赖，定期清理可释放磁盘空间
# 清理未被引用的包
pnpm store prune
# 查看存储占用
pnpm store status
```

## 最终效果

![ef2c3617_Pasted image 20260505184017.jpg](https://cdn.assets.inkyflow.com/content/posts/learning/Linux/ef2c3617_Pasted%20image%20260505184017.jpg)

---

> 作者: [人生一点墨](https://inkyflow.com)  
> URL: https://inkyflow.com/posts/learning/linux/02%E6%89%93%E9%80%A0-linux-%E7%B3%BB%E7%BB%9F%E5%BC%80%E5%8F%91%E7%AF%87/  

