How to open file in Emacs via eshell?

13.9k views Asked by At

When in eshell is there a command for opening a file in another buffer?

5

There are 5 answers

2
ataylor On BEST ANSWER

You can call elisp functions directly. So to open a file, call find-file on the filename. Example:

~ $ ls
myfile
~ $ (find-file "myfile")

Parentheses and quotes are optional, so this works too:

~ $ find-file myfile
2
tonka On

Why use eshell? 'C-x f' and type the location of your file.

0
Ryan Kung On

The elisp funct can be directly used in eshell, so you can try:

find-file <filename>
1
Androclus On

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

$ find-file myfile

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

$ alias ff 'for i in ${eshell-flatten-list $*} {find-file $i}'

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

$ ff myfile

thanks to this tutorial

0
Benjamin Handelman On

In eshell, you don't have to use the entire path when using the find file command. Hitting C-x C-f is the same as typing find-file, and eshell sets the directory to the one you are currently browsing. This is the advantage to me over using ansi-term. Try it out.