wsl下载ubuntu
1 2 3 4
| wsl --list --online
wsl --install Ubuntu-20.04
|
迁移到D盘
在D盘创建一个目录用来存放新的WSL,比如D:\WSL\Ubuntu-20.04
1 2 3 4 5 6 7
| wsl --export Ubuntu-20.04 D:\WSL\Ubuntu-20.04.tar
wsl --unregister Ubuntu-20.04
wsl --import Ubuntu-20.04 D:\WSL\Ubuntu-20.04 D:\WSL\Ubuntu-20.04.tar
|
如果这时候启动WSL,发现好像已经恢复正常了,但是用户变成了root。用以下命令恢复:
1
| Ubuntu2004 config --default-user username
|
安装最新版emacs
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
| sudo apt-get purge snapd
git clone https://github.com/tree-sitter/tree-sitter.git cd tree-sitter git checkout release-0.25 make make install PREFIX="$(pwd)/_install"
emacs _install/lib/pkgconfig/tree-sitter.pc prefix=/home/zhaohang/repository/tree-sitter/_install
export PKG_CONFIG_PATH="$HOME/repository/tree-sitter/_install/lib/pkgconfig:$PKG_CONFIG_PATH"
wget https://mirrors.ustc.edu.cn/gnu/emacs/emacs-30.2.tar.xz cd emacs-30.2 sudo apt install zlib1g-dev libgccjit-9-dev pkg-config libgnutls28-dev libncurses-dev
export LD_LIBRARY_PATH="$HOME/repository/tree-sitter/_install/lib:$LD_LIBRARY_PATH"
./configure \ --without-x \ --without-ns \ --without-pgtk \ --with-native-compilation \ --with-threads \ --with-tree-sitter \ --prefix=/usr/local \ LDFLAGS="-Wl,-rpath,$LD_LIBRARY_PATH -L$LD_LIBRARY_PATH"
make -j$(nproc) sudo make install
objdump -p /usr/local/bin/emacs | grep RUNPATH
|
--without-x emacs-nox,不使用 X11(Xorg),只能用 emacs -nw(终端)
--without-ns 禁用 macOS 的 Cocoa / NS 窗口系统,只是防止 configure 自动探测到 macOS GUI
--without-pgtk 禁用 Pure GTK(Wayland 下的新 GUI 后端)
--with-native-compilation 启用 native-comp(.eln)将Elisp 编译成机器码
--with-threads启用 多线程支持
--with-tree-sitter 启用tree-sitter
--prefix=/usr/local安装到 /usr/local
emacs配置参考:
另外通过apt下载的clangd版本比较老,可能不支持某些配置项,可通过下面命令安装较新的版本
1 2 3 4 5 6 7 8 9 10
| wget https://apt.llvm.org/llvm.sh chmod u+x llvm.sh sudo ./llvm.sh 21 sudo apt-get install clang-format-21
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-21 100 sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-21 100 sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-21 100 sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-21 100
|
git 版本比较低,不支持-b参数,可以添加apt源更新
1 2 3 4
| sudo add-apt-repository ppa:git-core/ppa -y sudo apt update sudo apt upgrade sudo apt install git -y
|
python 版本是3.8某些软件可能依赖3.9及以上的版本:
1 2 3 4 5 6 7 8 9 10 11
| sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install python3.9 python3-pip
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
sudo update-alternatives --config python3
|
bear 也可以使用最新版本,旧版本的bear是python脚本,效率偏低,而新版本是rust编写的二进制文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup update
git clone https://github.com/rizsotto/Bear.git cd bear cargo build --release
sudo install -m 755 target/release/bear /usr/local/bin/
export INSTALL_LIBDIR=lib/x86_64-linux-gnu sudo mkdir -p /usr/local/libexec/bear/$INSTALL_LIBDIR sudo install -m 755 target/release/libexec.so /usr/local/libexec/bear/$INSTALL_LIBDIR/
|

参考