emacs 中shell的配置文件在哪里呢?现在在emacs中使用shell模式,PS1提示内容都乱了~重启emacs也没用,所以肯定是被错误的写到文件了,但是我找不到该配置文件,有知道的吗?提示下,谢谢
提示符变成这样了^[]0;leo@ubuntu: ~^Gleo@ubuntu:~$
我重新下了一份新的配置,然后还是有同样的问题~
什么配置?Shell 的配置文件(Startup File)在终端和在 Emacs 中都一样吧?~/.bashrc
之类的,取决于你的 SHELL
你的意思是 M-x shell
?而不是 M-x term
或 eshell
?
这个推测很奇怪,你有没有首先确认下你设置的 Shell 的 Prompt 在 Emacs 中会不会乱?
emacs -Q -f shell
Emacs 或许不能像终端模拟器那样支持你的 Prompt。
shell-prompt-pattern我想应该是这个变量影响的吧。今天无意中看到的
是shell-mode,有一次不小心输入了一个回车,结果把buffer里的内容都当做命令执行了,从那以后命令提示符就不正常了~
有时候在终端 curl 一个二进制文件忘了设输出目标文件,导致 prompt 不正常,重启或(kill 当前任务,新开一个)就能恢复正常,除非没有真正重启。不知道你说的「乱」是不是这种情况。
如果 discribe 查看 shell-prompt-pattern 确实被改了,可能存在 ~/.emacs 或者 ~/.emacs.d/custom.el (具体看 custom-file 所指)。
我把配置全删了,现在再执行shell-mode报下面的错误~
Debugger entered--Lisp error: (wrong-type-argument processp nil)
process-command(nil)
shell-mode()
#<subr call-interactively>(shell-mode record nil)
ad-Advice-call-interactively(#<subr call-interactively> shell-mode record nil)
apply(ad-Advice-call-interactively #<subr call-interactively> (shell-mode record nil))
call-interactively(shell-mode record nil)
command-execute(shell-mode record)
helm-M-x(nil #("shell-mode" 0 10 (match-part "shell-mode")))
#<subr call-interactively>(helm-M-x nil nil)
ad-Advice-call-interactively(#<subr call-interactively> helm-M-x nil nil)
apply(ad-Advice-call-interactively #<subr call-interactively> (helm-M-x nil nil))
call-interactively(helm-M-x nil nil)
command-execute(helm-M-x)
没删干净,残留 ~/.emacs 或者 ~/.emacs.d/custom.el
我看了下,应该是.bashrc影响了,不过很奇怪为什么之前都好好的。
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
echo "hehe"
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
谢谢你,应该不是这个原因,这个是调整输出颜色的。 我最后修改好了,还是PS1变量设置的有问题,不知道当时为什么那样修改了~
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
最后,shell-mode最终还是调用了一个非登录交互式shell和emacs交互。