Is it possible to use colors in the Emacs shell prompt (the prompt itself, not the rest of the shell screen) with the bash PS1 variable? I believe I have the syntax correct
Figured it out: The comint-highlight-prompt
face was set to inherit from minibuffer-prompt
, which was setting the :weight
, :foreground
and :background
. Removing the inheritance prevented the colors set in PS1
from being overridden by the comint-highlight-prompt
face. Added this to my .emacs
file.
(set-face-attribute 'comint-highlight-prompt nil
:inherit nil)
Also, M-x customize-group <ret> font-lock-faces
was helpful in figuring this out.
I would recommend not to change the face globally (since there are many comint users besides shell mode) but in a buffer specific manner by setting a mode hook:
(add-hook 'shell-mode-hook
(lambda ()
(face-remap-set-base 'comint-highlight-prompt :inherit nil)))
You'll need to use ansi-term rather than shell for terminal colours.
I use that to change the terminal color and the information in mac, maybe can help:
Cyan="$(tput setaf 6)"
NC="$(tput sgr0)" # No Color
export PS1="$Cyan.Where-> \w\n\\$\[$NC\]"