windows 我可以在 Emacs 的 shell 模式下使用 PowerShell 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/872510/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I use PowerShell in shell-mode for Emacs?
提问by Cheeso
Can I use powershell as the shell, in shell mode for emacs?
How?
我可以在 emacs 的 shell 模式下使用 powershell 作为 shell 吗?
如何?
采纳答案by John D. Cook
See Jeffrey Snover's blog post PowerShell running inside of Emacs
请参阅 Jeffrey Snover 的博客文章PowerShell 在 Emacs 中运行
回答by Ray
Based on the blog post Run PowerShell as a shell within Emacs(April 2008), and the section of the Emacs Wiki article on PowerShell called PowerShell as an inferior shell(updated May 2010):
基于博客文章Run PowerShell as a shell in Emacs(2008 年 4 月),以及 Emacs Wiki 文章中关于 PowerShell 的部分称为PowerShell 作为劣质 shell(2010 年 5 月更新):
Save
powershell.el
in.\share\emacs\site-lisp
under the Emacs install directory, or any other directory in yourload-path
. (powershell.el
is too long to be included in this answer. As explained in the blog post, there is no way to force PowerShell to run in interactive mode when standard input and output are redirected, so a fair bit of glue code is needed to use it as an inferior shell.)Add the following to your
.emacs
file:(autoload 'powershell "powershell" "Run powershell as a shell within emacs." t)
保存
powershell.el
在.\share\emacs\site-lisp
Emacs 安装目录下,或load-path
. (powershell.el
太长,无法包含在此答案中。如博客文章中所述,当重定向标准输入和输出时,无法强制 PowerShell 在交互模式下运行,因此需要大量的胶水代码才能使用它作为劣质外壳。)将以下内容添加到您的
.emacs
文件中:(autoload 'powershell "powershell" "Run powershell as a shell within emacs." t)
Once done, use M-x powershell
to open and interactively use a PS shell buffer.
完成后,用于M-x powershell
打开和交互使用 PS shell 缓冲区。
回答by kotchwane
Instead of a whole package, I came up with a five-liners that works well enough for my needs. You might want to adapt it quickly.
我想出了一个五层衬里,而不是整个包装,它可以很好地满足我的需要。您可能想要快速适应它。
(defun powershell (&optional buffer)
"Launches a powershell in buffer *powershell* and switches to it."
(interactive)
(let ((buffer (or buffer "*powershell*"))
(powershell-prog "c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe"))
(make-comint-in-buffer "shell" "*powershell*" powershell-prog)
(switch-to-buffer buffer)))
回答by Charlie Martin
The quickest way to find out would be to run shell-mode, and then run powershell from the command line.
找出问题的最快方法是运行 shell-mode,然后从命令行运行 powershell。