在 Git 仓库间转移特定目录中的变更历史
- Mastering Git subtrees • Comprendre Git
- Add subdirectory of remote repo with git-subtree - Stack Overflow
我想把 old-repo 的某个目录连同它的变更历史一起转移到 new-repo 中。
cd new-repo
git remote add old ../old-repo
git fetch old some-branch
git checkout old/some-branch
git subtree split -P folder/in/old/repo -b split-branch
git checkout main
git subtree add --prefix=folder/in/new/repo split-branch重定义 GANSS GS87 键盘功能键区域
把之前写在 仓库的文件 记录在这里,记得每次系统更新后重新做一遍
- https://gist.github.com/taichunmin/3e348fe654f2a8acbcdd
- https://www.experts-exchange.com/articles/2155/Keyboard-Remapping-CAPSLOCK-to-Ctrl-and-Beyond.html
- https://www.tenforums.com/tutorials/167135-how-customize-disable-app-keys-keyboard-windows-10-a.html
- https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-appcommand
Windows Registry Editor Version 5.00
; 重定义 GANSS GS87 键盘功能键区域
; 这里修改 HKEY_CURRENT_USER 以避免权限问题
[-HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\7]
; 7 = APPCOMMAND_BROWSER_HOME
; 对应键盘的 Fn + F2
; 但如果当前聚焦于浏览器中,按键会被浏览器拦截,所以不建议使用此设定
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\16]
; 16 = APPCOMMAND_LAUNCH_MEDIA_SELECT
; 对应键盘的 Fn + F4
; 运行 orpheus:// 协议的关联程序,应该是网易云音乐
"Association"="orpheus"
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\17]
; 17 = APPCOMMAND_LAUNCH_APP1
; 对应键盘的 Fn + F1
; 打开 Obsidian
"ShellExecute"="obsidian://open"
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\18]
; 18 = APPCOMMAND_LAUNCH_APP2
; 对应键盘的 Fn + F3
; 运行 HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\wt.exe 对应的程序
; 也就是 WindowsTerminal from Microsoft Store
"ShellExecute"="wt"打开带有参数的 Obsidian URI 需要用 ShellExecute
Association 只能打开默认链接,很奇怪,应该像是访问 obsidian:// 一样,但实际却打开一个新窗口,让你选 Vault。
好在可以向键入到 ” 运行 ” 中一样用 ShellExecute 运行 obsidian://open
如果当前聚焦于浏览器中,APPCOMMAND_BROWSER_HOME 按键会被浏览器拦截
从源码来看 chrome/browser/ui/views/frame/browser_view.cc - chromium/src - Git at Google,会无条件处理 APPCOMMAND_BROWSER 这组按键,所以最好不要覆盖 APPCOMMAND_BROWSER_HOME 😅
之前 Edge Browser 在组策略中禁用快捷方式的路子在这里不起作用
在 Quicker 中使用鼠标屏幕边角触发
我没找到 Obsidian 的全局快捷键,同时我设置了 Windows 11 任务栏图标不合并但是隐藏标签 任务栏图标位置会变动,光用 Win+ 数字 不稳定。
设置这个快捷键的目的之一就是允许鼠标划到屏幕边角就打开 Obsidian,比去任务栏点图标快。
设置很简单,到 Quicker 设置 > 常用辅助功能 > 移动鼠标到屏幕角落。我选择右上,然后按键盘快捷键,会填入 LAUNCH_APP1
PVE 添加自定义 ACME Directory
在 v8 版本还能在 WebUI 上添加自定义 ACME 目录呢,升级到 v9 就只能通过命令行了 😑
$ pvenode acme account register lan-pki enihsyou@gmail.com
Directory endpoints:
0) Let's Encrypt V2 (https://acme-v02.api.letsencrypt.org/directory)
1) Let's Encrypt V2 Staging (https://acme-staging-v02.api.letsencrypt.org/directory)
2) Custom
Enter selection: 2
Enter custom URL: https://pki.lan.kokomi.site/acme/http/directory
Attempting to fetch Terms of Service from 'https://pki.lan.kokomi.site/acme/http/directory'..
No Terms of Service found, proceeding.
Attempting to register account with 'https://pki.lan.kokomi.site/acme/http/directory'..
Generating ACME account key..
Registering ACME account..
Registration successful, account URL: 'https://pki.lan.kokomi.site/acme/http/account/KMKLw3t3xOV8JPCSq24elg4LGrA4nK5U'
Task OK添加完记得处理 PVE 的 HTTPS 证书未按时续期
在 Taskfile 中写多行文本
version: "3"
tasks:
multiline-split:
desc: 单行拆多行,方便阅读
cmds:
- step ca certificate aria2 aria2.crt.pem aria2.key.pem
--force --kty=RSA --size=2048
multiline-heredoc:
desc: 多行 Heredoc 长文本
cmds:
- |
ssh RT-AX86U-CE58 << EOF
mkdir -p /jffs/tftpboot
cd /jffs/tftpboot
EOFDocker for Windows Path Bind
-v $(pwd):/buildout 一直给我提示 docker: invalid reference format
- `-v “g:/GitHub/netboot.xyz”:/buildout 尝试换成真实路径也不行
-v "//g/GitHub/netboot.xyz":/buildout尝试按照 AI 提示用双斜杠不行${pwd}并不是这个原因
最终发现是引号的位置,要把整个参数包起来 -v "$(PWD):/data"
PowerShell 给 Batch 文件传带引号的参数
在 PowerShell 中定义了个函数,只作透传作用,传递的命令有个参数,它必须当做一个整体传给下级命令,所以用引号包裹起来。
正常的 echo '"1"' 在 bash 中期望输出 "1",但从 PowerShell 绕一圈结果引号就不见了 pwsh -c 'echo '"1"''
正确的写法是 引号写两遍,pwsh -c 'echo ''"1"''',可如果要传递的参数放在变量里,这个方法就不管用了。
实际要处理的命令是 C:\msys64\msys2_shell.cmd -defterm -here -no-start -c 'echo "\"1\""',会发现即便写了两遍,执行起来也没有引号。
好在看来是 解析规则 的锅,因为这是 cmd 文件,做了特殊处理。可以通过设置 $PSNativeCommandArgumentPassing="Standard" 来获得类似 Linux 的体验。
$ $PSNativeCommandArgumentPassing="Windows"
$ Trace-Command -PSHOST -Name ParameterBinding -Expression { C:\msys64\msys2_shell.cmd -defterm -here -no-start -c 'echo "\"1\""' }
DEBUG: 2025-10-09 21:46:07.3373 ParameterBinding Information: 0 : BIND NAMED native application line args [C:\msys64\msys2_shell.cmd]
DEBUG: 2025-10-09 21:46:07.3466 ParameterBinding Information: 0 : BIND argument [-defterm -here -no-start -c "echo "\"1\"""]
DEBUG: 2025-10-09 21:46:07.3499 ParameterBinding Information: 0 : CALLING BeginProcessing
1
$ $PSNativeCommandArgumentPassing="Standard"
$ Trace-Command -PSHOST -Name ParameterBinding -Expression { C:\msys64\msys2_shell.cmd -defterm -here -no-start -c 'echo "\"1\""' }
DEBUG: 2025-10-09 21:46:23.1330 ParameterBinding Information: 0 : BIND NAMED native application line args [C:\msys64\msys2_shell.cmd]
DEBUG: 2025-10-09 21:46:23.1332 ParameterBinding Information: 0 : BIND cmd line arg [-defterm] to position [0]
DEBUG: 2025-10-09 21:46:23.1333 ParameterBinding Information: 0 : BIND cmd line arg [-here] to position [1]
DEBUG: 2025-10-09 21:46:23.1334 ParameterBinding Information: 0 : BIND cmd line arg [-no-start] to position [2]
DEBUG: 2025-10-09 21:46:23.1334 ParameterBinding Information: 0 : BIND cmd line arg [-c] to position [3]
DEBUG: 2025-10-09 21:46:23.1335 ParameterBinding Information: 0 : BIND cmd line arg [echo "\"1\""] to position [4]
DEBUG: 2025-10-09 21:46:23.1365 ParameterBinding Information: 0 : CALLING BeginProcessingMSYS2 的 PATH 来源
/usr/local/bin:/usr/bin:/bin:/opt/bin在 WSL2 中是由/etc/environment定义的 games,但 MSYS2 中由/etc/profile插入/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/也是/etc/profile中设置 ORIGINAL_PATH 后插入/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl由/etc/profile.d/perlbin.sh插入- 其余的在
$HOME/.profile以及它会 source 的$HOME/.bashrc中插入,并且会区分交互式终端
参考
Git Clone 自动使用 gh-proxy.com 镜像
最近 clone 速度越来越慢了,每次都要手动 git remote set-url 容易忘记,突发奇想能否自动切换。记得以前的 insteadOf 用来把 HTTP 切换到 SSH,应该也能用来改 URL
# use mirror for faster connection
[url "https://gh-proxy.com/github.com/"]
insteadOf = https://github.com/
# but keep the original for pushing
[url "https://github.com/"]
pushInsteadOf = https://github.com/第二段重写一遍是为了保持 push URL 不变
不过经过 GitHub Proxy 测速 之后,我选择 wget.la 当镜像。