Emacs中的cygwin外壳-输出混乱?

Emacs中的cygwin外壳-输出混乱?,emacs,cygwin,Emacs,Cygwin,我在这里看到了如何启动cygwin外壳的答案。然而,cygwin外壳的输出是混乱的 (defun cygwin-shell () "Run cygwin bash in shell mode." (interactive) (let ((explicit-shell-file-name "C:/cygwin/bin/bash")) (call-interactively 'shell))) (setq explicit-bash-args '("--login" "-i")

我在这里看到了如何启动cygwin外壳的答案。然而,cygwin外壳的输出是混乱的

(defun cygwin-shell ()
  "Run cygwin bash in shell mode."
  (interactive)
  (let ((explicit-shell-file-name "C:/cygwin/bin/bash"))
    (call-interactively 'shell)))
(setq  explicit-bash-args '("--login" "-i"))
这是shell的一个示例输出

]0;~
seth@seth ~
$ cd ~
]0;~
seth@seth ~
$ dir
]0;~
seth@seth ~
正如人们所看到的,输出被搞砸了。我该如何解决这个问题


编辑:我刚刚注意到^[]0总是出现在每个命令的末尾\否则输出文本可以正常工作。不管怎样,为了摆脱这个结局?

好吧,我想出来了。在~/.bashrc中,我添加了

export PS1="\e[0;31m[\u@\h \W]\$ \e[m "
这将使提示符在单行中变为红色(与原始cygwin提示符中的黄色相比,眼睛更容易看到!)

此外,您必须确保不使用dos结尾。要将dos结尾转换为unix,请键入C-x RET f unix并保存或放入.emacs文件

(set-buffer-file-coding-system 'unix)
调查。有了它,您的
.emacs
配置就变为

  (setq w32shell-cygwin-bin "c:\\cygwin\\bin")
  (require 'w32shell)
  (w32shell-add-emacs)
  (w32shell-set-shell "cygwin")

在Emacs24.2中,我不得不将Seth答案(2)中的
export PS1=…
行放在~/.Emacs\u bash中,而不是放在~/.bashrc中。

使用

export PS1="\e[0;32m\u@\h\e[m \e[0;33m\w\e[m\n\$ "
如果你想保留原来的颜色和格式