(require 'cl-lib)
(defun eat--exec-advice (original-fun buffer name command startfile &rest switches)
(let* ((flat-switches (cl-copy-list (flatten-list switches)))
(shell-candidate
(cond
((and (null switches) (file-name-nondirectory command))
command)
((member "-c" flat-switches)
(let ((idx (cl-position "-c" flat-switches :test #'equal)))
(when idx (nth (1+ idx) flat-switches))))
(t nil)))
(shell-name (when shell-candidate
(file-name-nondirectory shell-candidate)))
(shell-base (and shell-name
(car (split-string shell-name "[0-9]")))))
(if (member shell-base '("zsh" "bash"))
(funcall original-fun buffer name command startfile
(list "sh" "-c"
(format "
case $(basename \"%s\") in
zsh) exec zsh -c '. ~/.zshrc; source \"$EAT_SHELL_INTEGRATION_DIR/zsh\"; exec %s' ;;
bash) exec bash -c '. ~/.bashrc; source \"$EAT_SHELL_INTEGRATION_DIR/bash\"; exec %s' ;;
*) exec %s ;;
esac"
shell-candidate
shell-candidate
shell-candidate
shell-candidate)))
(apply original-fun buffer name command startfile switches))))
(advice-add #'eat-exec :around #'eat--exec-advice)
大部分由DS4生成,不得不说,的确比平价的其他模型聪明很多,AI确实能极大地减轻浪费在原型设计上的思想资源的消耗。
advice其实是我在vibe code时想到的,一开始用的另一个模型很笨,和它斗智斗勇浪费了我很多时间——既然DS4能沿着我的思路一下子就给出可用的结果,实现优不优雅也没什么可谈的了,能用就行。