我偶尔也会用 Windows 来打游戏,处理一些 Windows 限定的内容。但是更多的是在 Windows
虚拟机内运行。
1. Emacs 相关配置 Emacs
1.1. 使用 Msys2 编译并安装 Emacs outdated
1.1.1. 使用 Msys2 安装依赖
$ pacman -S --needed base-devel \ mingw-w64-x86_64-toolchain \ mingw-w64-x86_64-xpm-nox \ mingw-w64-x86_64-libtiff \ mingw-w64-x86_64-giflib \ mingw-w64-x86_64-libpng \ mingw-w64-x86_64-libjpeg-turbo \ mingw-w64-x86_64-librsvg \ mingw-w64-x86_64-lcms2 \ mingw-w64-x86_64-jansson \ mingw-w64-x86_64-libxml2 \ mingw-w64-x86_64-gnutls \ mingw-w64-x86_64-zlib \ mingw-w64-x86_64-harfbuzz
1.1.2. 编译 Emacs 并安装
笔者写了个脚本,用来编译 Emacs 并安装
#!/usr/bin/env bash set -e SCRIPT_PATH="$0" DIR_PATH="${SCRIPT_PATH%/*}" EMACS_SRC_DIR="/e/repos/emacs" cd "$EMACS_SRC_DIR" ./autogen.sh ./configure \ --without-pop \ --with-native-compilation \ --enable-link-time-optimization \ --with-dbus \ --with-sound=no make NATIVE_FULL_AOT=1 -j$(nproc) make install # 我统一在一个目录中管理我的所有配置文件,但是 Windows 缺乏对应软链接工具,所以在初始化 Emacs 配置之前,我需要指定真正的配置文件位置 cat <<EOF > "C:/msys64/mingw64/share/emacs/site-lisp/site-start.el" (setenv "HOME" (concat "C:/msys64/home/" (getenv "USER"))) (setq user-init-file "$DIR_PATH/init.el") (load user-init-file) EOF
1.2. 其他设置
1.2.1. 在任务栏创建 emacsclient 快捷方式
用来加快在 Windows 下的启动速度。
- 任务栏固定 emacs.exe
修改属性 (alt + shift + right click),将其中的地址修改为
C:\msys64\mingw64\bin\emacsclientw.exe -n -c -a ""
1.2.2. 禁用 Ctrl-Space
Ctrl-Space 在 Windows 中默认用来切换输入法,但是笔者更习惯使用它来切换选择标记。网上提供了很多方法来对其进行切换,包括使用 AutoHotKey 等软件,但是 Windows 10 中提供设置禁用切换输入法这个功能。
具体方法为:
- 在托盘区域的输入法上右键单击。
- 进入
设置
。 - 进入
按键
设置 - 在
模式切换
中反选Ctrl+Space
此时 Windows 就不会拦截该快捷键,可以用于 Emacs 编辑相关的键位绑定中。
1.2.3. 绑定 s-x
启动 Emacs
使用 autoHotKey
LWin & x:: emacsclient --no-wait -a "" -e "(if (frame-focus-state) (lower-frame) (raise-frame))" Return
2. WezTerm 相关配置 Wezterm
local wezterm = require 'wezterm' return { default_prog = { 'C:\\msys64\\usr\\bin\\zsh.exe', '-l' }, font = wezterm.font 'JetBrains Mono', color_scheme = 'zenbones', set_environment_variables = { CHERE_INVOKING = 'enabled_from_arguments', HOME = 'E:\\Home', WENV = 'D:\\wenv' } }
3. 为默认输入法开启小鹤双拼
同样是一份注册表配置,保存为 reg 文件后直接双击安装到注册表,之后在输入法设置中选择小鹤双拼即可。
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\InputMethod\Settings\CHS] "Enable Double Pinyin"=dword:00000001 "DoublePinyinScheme"=dword:0000000a "Expand Double Pinyin"=dword:00000000 "UserDefinedDoublePinyinScheme0"="XiaoHe*2*^*iuvdjhcwfg xmlnpbksqszxkrltvyovt"
4. 按键映射
4.1. 将 caps 映射为 control 键
对于日常使用 ctrl 非常频繁的人来说,将 caps 映射为 ctrl 可以省力很多。
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
4.2. Windows 使用 UTC 时间
Linux 与 Windows 默认硬件时间配置不同,GNU/Linux 下推荐使用 UTC,但是 Windows 推荐使用本地时间。双方都会尝试写入到 BIOS 中,因此会发生冲突。考虑到 GNU/Linux 系统的包同步情况,我决定采用 GNU/Linux 方案,因此需要修改 Windows 的配置。
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation] "RealTimeIsUniversal"=hex(b):01,00,00,00,00,00,00,00
将上面的代码保存为 reg 文件,即可安装到注册表中,重启后生效。