eshell
是按当前buffer的目录的,所以可以with-temp-buffer
,但是如果那个目录还没有任何文件被打开,就会有个打开文件(或者别的比如dired之类的buffer)的overhead。当前代码:
(defun my/shell-for-node.js ()
"For buffer file, look up directories and find package.json, open a shell there."
(interactive)
(with-current-buffer (dired (locate-dominating-file (buffer-file-name) "package.json"))
(eshell)))
cireu
2
(let ((default-directory "/tmp"))
(eshell))
default-directory
变量就如同shell里的pwd,改变他就如同cd
4 个赞
推荐用aweshell,这些都有,想要传统一点的体验(tab补全而不是company)可以用参考fshell
对,「当前工作路径」在 Shell 和 Emacs 中分别用环境变量 PWD
和 变量 default-directory
表示,Shell 中每一个提示符都对应着一个「当前工作路径」,Emacs 中每一个 Buffer 都对应一个「当前工作路径」。
1 个赞
用了用了,上面写eshell
是为了更generic
aweshell有一个函数aweshell-toggle
,C-u调用可以在当前目录打开。
啥,装了aweshell之后开eshell就是awesome的啊