0

After executing the shell command, I have a shell buffer inside Emacs.

After executing classic ls -l, there is a file listed that I want to open in Emacs:

[pedro@system:~/projects/career-opportunities]$ ls -l
total 4
-rw-r--r-- 1 pedro users 58 Mar 23 12:05 README.md

Thus, I execute:


[pedro@system:~/projects/career-opportunities]$ emacs README.md 

Emacs opens the README file. But, the file is open in another Emacs application. I would like to open this file in the current Emacs application.

Of course, I could use find-file with the classic binding of C-x C-f (or counsel-find-file in my case). Also, I could use dired and press return on the desired file. Anyways, I think there is a way to do what I want with shell. So, I would like to use shell better and this seems appropriate to learn.

3
  • 1
    I have no doubts that what you want is possible. The key aspect is: why would you want that? When you start M-x shell you're starting a bash process. If you want a tighter integration between emacs and the shell, then perhaps you should take a look at eshell.
    – aadcg
    Mar 23, 2022 at 17:35
  • 3
    Replace emacs by emacsclient in yr shell invocation and you are done (so long as you are running the emacs server). Mar 23, 2022 at 17:37
  • 1
    Ultimately, my point is: Emacs is a shell, i.e. the outer layer between you (the computer user) and the OS. The common shell languages (bash, sh, fish, whatever) are inferior (bare-bones) shells, though useful in some situations.
    – aadcg
    Mar 23, 2022 at 17:38

1 Answer 1

0

As indicated by Fran Burstall (thank you!) via a comment in my question, I just need to do:

[pedro@system:~/projects/my-blog]$ emacsclient README.md 
Waiting for Emacs...

The chosen file opens in a new buffer. And the shell buffer indicates a new message with Waiting for Emacs:

[pedro@system:~/projects/my-blog]$ emacsclient README.md 
Waiting for Emacs...

Quite cool! I did not know about that :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.