如何使用 Powershell 作为我的 trapmp-encoding-shell?

2024-03-19

首先我启动 eshell 然后输入命令cd /plink:<user>@<host>:/home/

然后我收到此错误消息

Microsoft Windows [版本 6.1.7601] 版权所有 (c) 2009 Microsoft 公司。版权所有。

命令提示符已被您的管理员禁用。

按任意键继续 。 。 。

我正在尝试与 plink (在我的路径中)连接,也在通过 *Messages* 缓冲区后我发现了这个。

找不到 (C:\Windows\system32\cmd.exe) 的本地 shell 提示

我 90% 确定这是因为我的计算机上已禁用 cmd,因为当我在另一台计算机上尝试相同的设置时,我知道 cmd 已启用,一切正常。

我已经修改了我的.emacs文件有

(require 'tramp)
(set 'tramp-encoding-shell "C:/Windows/System32/WindowsPowershell/v1.0/powershell.exe")
(set 'tramp-encoding-command-switch "-Command")

我得到了不同的结果,但是结果似乎是乱七八糟的废话(第三行看起来可能是一个提示,\ and >字符位于正确的位置...)。

我设法挖了一个相当不错的描述 https://lists.gnu.org/archive/html/tramp-devel/2009-06/msg00009.html什么的tramp-encoding-shell是,还有一个相关的所以问题 https://stackoverflow.com/questions/29477035,这是tramp-encoding-shell 来源/文档 https://github.com/emacs-mirror/emacs/blob/28caedba0f5c387d9c8e8fc8de26b5399afeb68b/lisp/net/tramp.el#L154-L178在 github 上。

Update

这是我尝试使用 powershell 设置为 trap-encoding-shell 来打开 plink 连接失败后的屏幕显示。


所以我不知道 TRAMP,但你得到的解释是 Windows PowerShell 向你发送回 unicode (UTF16),每个字符都是 16 位,在本例中是字母和零,加上行尾是回车符 /换行(0xa、Oxd)。

Now for “emacs 找不到 PowerShell 的本地 shell 提示符”错误根据TRAMP 文档 http://www.gnu.org/software/tramp/ @迈克尔·阿尔比努斯建议似乎很有希望。

6.4.2 在远程主机上运行shell

在与远程主机相关的缓冲区中调用 M-x shell 会运行本地 shell,如shell-file-name。这也可能是要在远程主机上应用的 shell 的有效文件名,但至少当本地和远程主机属于不同的系统类型(例如“windows-nt”和“gnu/linux”)时,它会失败。

您必须设置变量explicit-shell-file-name添加到远程主机上的 shell 文件名,以便在远程主机上启动该 shell。

6.4.6 在 Windows 主机上运行远程进程在 winexe 的帮助下,可以在远程 Windows 主机上运行进程。 TRAMP 已为进程文件和启动文件进程实现了此功能。

变量tramp-smb-winexe-program必须包含本地winexe命令的文件名。远程主机上必须安装Powershell V2.0;它用于运行远程进程。

为了通过 M-x shell 在 Windows 主机上打开远程 shell,您必须设置变量explicit-shell-file-name 和explicit-*-args。例如,如果您想运行 cmd,则必须设置:

(setq explicit-shell-file-name "cmd"
      explicit-cmd-args '("/q"))

如果将 powershell 作为远程 shell 运行,则设置为

(setq explicit-shell-file-name "powershell"
      explicit-powershell-args '("-file" "-"))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 Powershell 作为我的 trapmp-encoding-shell? 的相关文章

随机推荐