如何让Emacs shell模式呈现(或忽略)我的颜色而不是打印ASCII代码?

时间:2022-03-31 23:02:26

The symptom of the problem looks like "[0m[27m[24m[J[34;1" which on a terminal translates into the color blue.

问题的症状看起来像“[0m [27m [24 [J [34; 1”]在终端上转换为蓝色。

-A

4 个解决方案

#1


32  

I've got the following in my .emacs

我的.emacs中有以下内容

(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

#2


2  

The solution that is currently giving me some success is to redefine the shell function as an ansi term:

目前给我一些成功的解决方案是将shell函数重新定义为ansi术语:

;; shell-mode
(defun sh ()
  (interactive)
  (ansi-term "/bin/zsh"))

#3


1  

For the "ignore" alternative, put something like "alias ls=ls" or "unset LS_COLORS" in your ~/.emacs_{bash,tsch,whatever-your-shell-is-called} file. This file is executed in all subordinate shells created by emacs.

对于“忽略”替代方案,在〜/ .emacs_ {bash,tsch,whatever-your-shell-is-called}文件中添加类似“alias ls = ls”或“unset LS_COLORS”的内容。此文件在emacs创建的所有从属shell中执行。

Emacs sends the new shell the contents of the file ~/.emacs_shellname as input, if it exists, where shellname is the name of the file that the shell was loaded from. For example, if you use bash, the file sent to it is ~/.emacs_bash. If this file is not found, Emacs tries to fallback on ~/.emacs.d/init_shellname.sh.

Emacs将新shell发送文件〜/ .emacs_shellname的内容作为输入(如果存在),其中shellname是从中加载shell的文件的名称。例如,如果您使用bash,发送给它的文件是〜/ .emacs_bash。如果找不到此文件,Emacs会尝试回退〜/ .emacs.d / init_shellname.sh。

#4


0  

The following should work in your .bash_profile or .bashrc

以下内容适用于.bash_profile或.bashrc

case $TERM in
xterm-color)
export PS1='\[\e]0;\W\007\]\[\e[34;1m\]\W\[\e[0m\]\$ '
;;
*)
export PS1='\W\$ '
;;
esac

#1


32  

I've got the following in my .emacs

我的.emacs中有以下内容

(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

#2


2  

The solution that is currently giving me some success is to redefine the shell function as an ansi term:

目前给我一些成功的解决方案是将shell函数重新定义为ansi术语:

;; shell-mode
(defun sh ()
  (interactive)
  (ansi-term "/bin/zsh"))

#3


1  

For the "ignore" alternative, put something like "alias ls=ls" or "unset LS_COLORS" in your ~/.emacs_{bash,tsch,whatever-your-shell-is-called} file. This file is executed in all subordinate shells created by emacs.

对于“忽略”替代方案,在〜/ .emacs_ {bash,tsch,whatever-your-shell-is-called}文件中添加类似“alias ls = ls”或“unset LS_COLORS”的内容。此文件在emacs创建的所有从属shell中执行。

Emacs sends the new shell the contents of the file ~/.emacs_shellname as input, if it exists, where shellname is the name of the file that the shell was loaded from. For example, if you use bash, the file sent to it is ~/.emacs_bash. If this file is not found, Emacs tries to fallback on ~/.emacs.d/init_shellname.sh.

Emacs将新shell发送文件〜/ .emacs_shellname的内容作为输入(如果存在),其中shellname是从中加载shell的文件的名称。例如,如果您使用bash,发送给它的文件是〜/ .emacs_bash。如果找不到此文件,Emacs会尝试回退〜/ .emacs.d / init_shellname.sh。

#4


0  

The following should work in your .bash_profile or .bashrc

以下内容适用于.bash_profile或.bashrc

case $TERM in
xterm-color)
export PS1='\[\e]0;\W\007\]\[\e[34;1m\]\W\[\e[0m\]\$ '
;;
*)
export PS1='\W\$ '
;;
esac