46

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

ismail
  • 46,010
  • 9
  • 86
  • 95
hks
  • 757
  • 1
  • 6
  • 13

5 Answers5

58

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
Onorio Catenacci
  • 14,928
  • 14
  • 81
  • 132
ataylor
  • 64,891
  • 24
  • 161
  • 189
  • 1
    I don't think this really answers the "meant" question, but it answers the asked question. What I mean is that people finding this question are probably looking for a command line command to type in eshell, maybe because they do not want to use `C-x C-f`, for whatever reason. – Zelphir Kaltstahl Oct 12 '17 at 10:07
  • 2
    I usually have emacs split into two windows, and want to open the file in the other window, instead of replacing my eshell session: `find-file-other-window myfile` – Nick Jan 10 '19 at 22:23
16

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.

7

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

Androclus
  • 221
  • 2
  • 4
2

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

find-file <filename>
Ryan Kung
  • 253
  • 1
  • 6
0

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

tonka
  • 11
  • 1
    Well it's just the thing that I don't want to type an entire path since I'm already at some location in shell. Still I guess that at some point of my emacs adventure I'm going to use dired. In a ['commander way'](http://www.emacswiki.org/emacs/Sunrise_Commander) – hks Feb 16 '11 at 23:29
  • 1
    I think if you try it you will discover that 'C-x C-f' actually opens in the directory you're browsing. Plus you'll get ido completion! – jhau Aug 25 '14 at 15:12