问题的症状看起来像“[0m[27m[24m[J[34;1””,在终端上转换为蓝色。
-一种
我有以下内容.emacs
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
目前给我一些成功的解决方案是将 shell 函数重新定义为 ansi 术语:
;; shell-mode
(defun sh ()
(interactive)
(ansi-term "/bin/zsh"))
对于“忽略”替代方案,请在文件中添加“ alias ls=ls
”或“ unset LS_COLORS
”之类的~/.emacs_{bash,tsch,whatever-your-shell-is-called}
内容。该文件在 emacs 创建的所有从属 shell 中执行。
Emacs向新的 shell 发送文件的内容
~/.emacs_shellname
作为输入,如果存在,其中shellname
是从中加载 shell 的文件的名称。例如,如果您使用 bash,则发送给它的文件是~/.emacs_bash
. 如果找不到这个文件,Emacs 会尝试回退到~/.emacs.d/init_shellname.sh
.
以下内容应适用于您的 .bash_profile 或 .bashrc
case $TERM in
xterm-color)
export PS1='\[\e]0;\W\007\]\[\e[34;1m\]\W\[\e[0m\]\$ '
;;
*)
export PS1='\W\$ '
;;
esac