我正在尝试开始在 emacs 中使用 eshell 代替 bash,但我严重依赖多年来编写的 bash 函数。我想将 eshell 配置为在出现“未找到命令”情况时调用 bash,以防相关命令作为 bash 函数实现。
有一个名为 eshell-alternate-command-hook
的变量,听起来像是定制的,但我认为我缺乏 elisp 技能,这妨碍了我的成功。
这是我最大的努力:
(add-hook 'eshell-alternate-command-hook 'invoke-bash t t)
(defun invoke-bash (command args)
(throw 'eshell-replace-command
(list "bash -c" command args)))
但是当我测试它时,它不起作用:
c:/temp $ lsd
Wrong number of arguments: (lambda (command args) (throw (quote eshell-replace-command) (list "bash -c" command args))), 1
c:/temp $
最佳答案
这是我最终想出的:
(defun invoke-bash (command)
(progn
(setq invoke-bash-cmd (concat "bash -c \"" command " " (mapconcat 'identity eshell-last-arguments " ") "\""))
(message invoke-bash-cmd)
(throw 'eshell-replace-command
(eshell-parse-command invoke-bash-cmd))))
关于emacs - 如何为 emacs eshell 定义备用命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9420270/