Emacs dired-mode: how to "exit" and end in a shell in the current directory?

On Mac OS, I can use a terminal, write "cd", and then drag and drop folders from the Finder onto the terminal. Then I get something like "cd / Users / ...", which allows me to quickly navigate to the corresponding directory. If I open the emacs shell with the Mx shell and drag the folder there, emacs will change in standby mode and display the contents of the folder that I reset. How can I β€œexit” or β€œexit” in standby mode and get a shell that has a directory that has been changed to a folder that I reset? That would give me something like the above, and that would be very helpful.

+8
emacs dired
source share
1 answer

You can implement a function that opens a shell instead of a processed buffer. This function is useful in many other cases, not only in the case of DnD

(require 'dired) (define-key dired-mode-map "c" 'shell-instead-dired) (defun shell-instead-dired () (interactive) (let ((dired-buffer (current-buffer))) (shell (concat default-directory "-shell")) (kill-buffer dired-buffer) ;; remove this line if you don't want to kill the dired buffer (delete-other-windows))) 

EDIT In this case, you need to create the DnD directory in Emacs and press "c" to invoke the shell in this directory.

Otherwise, you can install the smart-dnd package and configure it to open the shell. I also provide other useful things, such as creating <img ...> tags in html mode if you drop jpg or #include<...> in c mode if you drop header.

+6
source share

All Articles