安装ArchLinux
- 下载LxRunOffline
- 下载ArchLinux(注意是tar.gz)文件
- 执行命令
.\LxRunOffline.exe i -n Arch -f D:\Virtual_Images\archlinux-bootstrap-2024.04.01-x86_64.tar.gz -d D:\Arch -r root.x86_64
- 设置Arch的分发版本
wsl --set-version Arch 2
- 设置wsl2的配置文件.wslconfig,位置在用户目录下,没有就创建一个,这是wsl的全局配置文件,具体配置参考官网
[experimental] networkingMode=mirrored dnsTunneling=true firewall=true autoProxy=true hostAddressLoopback=true [wsl2] swap=0 processors=8 memory=4GB
- 进入Arch系统
wsl -d Arch
- 删除/etc/resolv.conf文件
rm /etc/resolv.conf
- 编辑/etc/wsl.conf文件,添加下面内容。
#不加载Windows中的PATH内容,不然可能与Arch里面PATH变量冲突 [interop] appendWindowsPath = false
- 退出系统重启
wsl --shutdown -d Arch ; wsl -d Arch
- 因为系统很简陋,没有vim编辑器,所以我们在windows下修改/etc/目录下的配置文件,window文件资源管理器可以直接查看和修改Arch的文件。
- 找到/etc/pacman.conf添加下面内容
# [custom] SigLevel = Optional TrustAll [archlinuxcn] Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch
- 编辑/etc/pacman.d/mirrolist文件,将China的源注释去掉
- 如果在执行第10步出现Signing Key错误什么的,在/etc/pacman.conf中找到下面相关代码并修改SigLevel=Never。
# By default, pacman accepts packages signed by keys that its local keyring # trusts (see pacman-key and its man page), as well as unsigned packages. SigLevel = Never LocalFileSigLevel = Optional #RemoteFileSigLevel = Required
- 找到/etc/pacman.conf添加下面内容
- 在Arch中执行下面代码
pacman -Syy pacman-key --init pacman-key --populate pacman -S archlinuxcn-keyring pacman -S base base-devel vim git wget
- 添加用户
在/etc/sudoers文件中添加useradd -m -G wheel -s /bin/bash sunset passwd sunset
sunset ALL=(ALL:ALL) ALL
- 给root用户添加密码
passwd
- wsl备份
# 导出 wsl --export Arch Arch.tar # 导入 wsl --import Arch Arch.tar
终端美化
- 下载zsh
pacman -S zsh
- 更改shell
chsh -s /bin/zsh
- 下载oh-my-zsh(终端需要安装一些字体,不然有的字符不会显示,如NerdFont)
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
- 查看自带主题和插件
ls $ZSH/plugins/ ls $ZSH/themes/
- 插件安装
#命令自动建议 git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions #命令语法高亮 git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting #历史命令查找,ctrl+r触发 git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search #配置文件添加 plugins=(zsh-autosuggestions zsh-syntax-highlighting zsh-history-substring-search)
- 安装powerlevel10k主题,参考这里
修改~/.zshrc中ZSH_THEME=“powerlevel10k/powerlevel10k”git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
然后source ~/.zshrc - 安装neofetch,可以在进入系统的时候显示有关系统软硬件的信息
pacman -S neofetch #neofetch 添加到~/.zshrc echo "neofetch" >> ~/.zshrc source ~/.zshrc
语言环境配置
安装python
pacman -S python python-pip
设置pip镜像源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
安装nodejs
pacman -S nodejs
设置npm镜像源
npm config set registry https://registry.npmmirror.com
安装Rust
export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
curl --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh
设置cargo镜像源
[source.crates-io]
# To use sparse index, change 'rsproxy' to 'rsproxy-sparse'
replace-with = 'rsproxy'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true
设置rustup的镜像源,以便下载其他的target或者升级rust,然后在~/.zshrc追加以下内容,最后source ~/.zshrc
export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
source $HOME/.cargo/env
文本编辑器配置
安装code-server
pacman -S code-server
对于没有GUI的ArchLinux安装一个code-server足以应对大部分开发需求。
编辑~/.config/code-server/config.yaml
bind-addr: 0.0.0.0:8080
auth: password # 启用密码认证,none代表没有密码
password: 123456 #
cert: false
安装helix
pacman -S helix
helix详细用法参考官方document
helix配置各种语言的lsp参考这里
#可以查看helix对于该语言的支持情况
helix --health rust
#查看支持的所有语言
helix --helix
配置js和ts的lsp
这里选用deno作为js和ts的lsp,因为deno的工具链非常完善。
需要先安装deno
pacman -S deno
编写languages.toml,保存在~/.config/helix/路径下。
[[language]]
name = "javascript"
shebangs = ["deno"]
roots = ["deno.json", "deno.jsonc"]
file-types = ["js"]
language-servers = ["deno-lsp"]
auto-format = true
[[language]]
name = "typescript"
shebangs = ["deno"]
roots = ["deno.json", "deno.jsonc"]
file-types = ["ts"]
language-servers = ["deno-lsp"]
auto-format = true
[[language]]
name = "jsx"
shebangs = ["deno"]
roots = ["deno.json", "deno.jsonc"]
file-types = ["jsx"]
language-servers = ["deno-lsp"]
auto-format = true
[[language]]
name = "tsx"
shebangs = ["deno"]
roots = ["deno.json", "deno.jsonc"]
file-types = ["tsx"]
language-servers = ["deno-lsp"]
auto-format = true
[language-server.deno-lsp]
command = "deno"
args = ["lsp"]
environment = { NO_COLOR = "1" }
[language-server.deno-lsp.config.deno]
enable = true
# Uncomment to enable completion of unstable features of Deno
# unstable = true
# Uncomment to cache dependencies on save
# cacheOnSave = true
# Enable completion of importing from registries
# Enable completion of function calls
suggest = { completeFunctionCalls = false, imports = { hosts = { "https://deno.land" = true } } }
# suggest = { imports = { hosts = { "https://deno.land" = true, "https://crux.land" = true, "https://x.nest.land" = true } } }
# Uncomment to enable inlay hints
# inlayHints.parameterNames.enabled = "all"
# inlayHints.parameterTypes.enabled = true
# inlayHints.variableTypes.enabled = true
# inlayHints.propertyDeclarationTypes.enabled = true
# inlayHints.functionLikeReturnTypes.enabled = true
# inlayHints.enumMemberValues.enabled = true
其他Linux命令行小工具安装
- btop,一款服务器资源监控工具。
- tmux,终端复用工具。
- cloc,代码统计工具。
- axel,多线程下载工具。
- fzf,模糊搜索工具。
- fd,速度超快的命令行搜索工具。
- exa,一个用来替代 ls 的工具。
- bat,显示文件内容的工具,可以代替cat。
- wrk,轻量级的 HTTP 性能测试工具。
- duf,用来显示磁盘占用情况,代替df。
- ncdu,用来显示每个目录占用的大小,代替du。