我可以在Emacs的shell模式下使用PowerShell作为默认的shell吗?
如何实现?
我可以在Emacs的shell模式下使用PowerShell作为默认的shell吗?
如何实现?
请查看Jeffrey Snover的博客文章PowerShell在Emacs中运行
基于博客文章在Emacs中作为shell运行PowerShell(2008年4月)和Emacs Wiki上关于PowerShell的部分,称为将PowerShell作为次要shell(更新于2010年5月):
将powershell.el
保存在Emacs安装目录下的.\share\emacs\site-lisp
或任何其他load-path
中的目录中。(powershell.el
太长了,无法包含在此答案中。如博客文章所述,当标准输入和输出被重定向时,没有办法强制PowerShell以交互模式运行,因此需要相当多的粘合代码来将其用作较低级别的shell。)
将以下内容添加到你的.emacs
文件中:
(autoload 'powershell "powershell" "Run powershell as a shell within emacs." t)
完成后,使用M-x powershell
打开并交互使用PS shell缓冲区。
与其使用一整个包,我想出了一个只有五行代码的方案,它已经满足我的需求。你可能想要快速地调整它来适应自己的需求。
(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)))
emacs-26.3-x86_64-no-deps
运行良好。 - ucsky最快的方法是运行shell模式,然后从命令行运行powershell。