如何通过eshell在Emacs中打开文件?

hks*_*hks 35 emacs buffer eshell

在eshell中是否有用于在另一个缓冲区中打开文件的命令?

ata*_*lor 48

您可以直接调用elisp函数.所以要打开文件,请调用find-file文件名.例:

~ $ ls
myfile
~ $ (find-file "myfile")
Run Code Online (Sandbox Code Playgroud)

括号和引号是可选的,所以这也适用:

~ $ find-file myfile
Run Code Online (Sandbox Code Playgroud)

  • 我通常将 emacs 分成两个窗口,并希望在另一个窗口中打开文件,而不是替换我的 eshell 会话: `find-file-other-window myfile` (3认同)

小智 13

在eshell中,使用find file命令时不必使用整个路径.点击Cx Cf与输入find-file相同,eshell将目录设置为您当前正在浏览的目录.这对我来说比使用ansi-term更有优势.试试看.


and*_*lus 5

find-file basically does it, as ataylor and ryan kung indicated earlier.

$ find-file myfile
Run Code Online (Sandbox Code Playgroud)

but, using eshell itself, you can also can set an even shorter alias:

$ alias ff 'for i in ${eshell-flatten-list $*} {find-file $i}'
Run Code Online (Sandbox Code Playgroud)

(and eshell remembers it permanently). so from now you can just type:

$ ff myfile
Run Code Online (Sandbox Code Playgroud)

thanks to this tutorial