Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Dired, copying is done like "copy the marked files to somewhere else". Is there a way to do this in the opposite direction?

That is, in the scenario I imagine I would get a question what to copy (path), and it would be copied / symlinked into the current directory. (In a "let's collect all the stuff that's needed to run a command in one place" way, for example.)

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

M-x copy-file RET will prompt for the source file, then default to the current directory. You could bind that to a key.

Or, if that's not good enough, let me know and I'll write the command and post it.

Eh, I had some time, so here's the command:

(defun dired-copy-file-here (file)
  (interactive "fCopy file: ")
  (copy-file file default-directory))
(eval-after-load "dired"
  '(define-key dired-mode-map "\M-c" 'dired-copy-file-here))
share|improve this answer
thanks, that's exactly what I was looking for! –  Latanius Oct 24 '12 at 0:54
add comment

As Aurélien mentions, the only advantage you gain from being in a specific Dired buffer seems to be . means "here", so going for a shell cp is almost all you can do.

The other advantage that comes to my mind is, if you have another visible dired buffer (C-x2..), when you move/copy/link from the buffer you're in (from which you select all your files, therefore), emacs gives you some default targets as destinations, which are accessible with the <down> arrow when you're prompted in the minibuffer.

Say you have 2 dired buffers open, ~/here/ and ~/elsewhere/someplace/, then selecting a few files in ~/here/, pressing C in that buffer, then should give you the default option to copy stuff to ~/elsewhere/someplace/. Same for single files, you get the default directory, and the default directory+filename (e.g. ~/here/some long annoying filename you'd like to edit.any~/elsewhere/someplace/some long annoying filename you'd like to edit.any).

Just press again for more defaults.

share|improve this answer
yours is not the answer I asked for but the answer I would have asked for if... I knew the answer... never mind, fact is that it seems to be a really good workflow! I also encountered the variable dired-dwim-target, for one less down arrow, might be useful. –  Latanius Oct 24 '12 at 1:00
add comment

You can do something like


to execute a shell command and then

cp -r what_to_copy(path) ./
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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