On Mac OS I can use the terminal, write "cd ", and then drag & drop folders from Finder to the terminal. I then obtain something like "cd /Users/..." which allows me to quickly change to the corresponding directory. If I open an emacs shell with M-x shell and drag & drop a folder to it, emacs changes in dired mode and displays me the content of the folder I dropped. How can I "exit" or "quit" dired-mode and obtain a shell having directory changed to the folder I dropped? That would give me something like above and that would be quite useful.
Dired makes an Emacs buffer containing a listing of a directory, and optionally some of its subdirectories as well. You can use the normal Emacs commands to move around in this buffer, and special Dired commands to operate on the listed files. Dired works with both local and remote directories.
Open dired for a directory containing files you want to work with. Then use C , R , or D when the cursor is on the line of a file to copy, rename/move or delete the file, respectively. This can also be done for multiple files by marking them.
You can implement a function to open a shell instead of dired buffer. This function is useful in many other cases, not only in a 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 DnD a directory in Emacs and press 'c' to call a shell in this directory.
Otherwise you may install a smart-dnd package and configure it to open a shell. I provides also other useful stuff like creating <img ...>
tags in html mode if you drop a jpg or #include<...>
in c-mode if you drop a header.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With