Is there any easy way to open the system command line interface (e.g., cmd in Windows) at the directory containing the current buffer (if any)? Note that M-x shell open a command line interface within emacs, hence does not answer the question. I also tried M-x shell-command cmd but this also open the command line interface within emacs.

  • What happens if you type ! on directory name and then cmd when prompted for the program to run? I cannot test this on Windows. – wvxvw Jun 14 '17 at 12:23
  • Thank you for your comment, I don't understand by what you mean to type ! on directory name and then cmd. Do you mean to do M-! then giving cmd? – Name Jun 14 '17 at 13:13
  • In dired buffer ! is bound to dired-do-shell-command, so pressing it would be similar to M-! except Emacs automatically sets some parameteres for the command invoked, such as "current directory". – wvxvw Jun 14 '17 at 14:29

You need to use start cmd to get a new terminal window. Use M-& (async-shell-command) to avoid blocking Emacs. This creates a useless *Async Shell Command* buffer, you can use the start-process-shell-command function to avoid this:

(start-process-shell-command (format "cmd(%s)" default-directory) nil "start cmd")
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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