2

Any other shell besides eshell and shell in Spacemacs with Emacs v25.1.1 (GUI version) looks like this:

Weird terminal

To compare, the terminal in iTerm looks like this:

Proper terminal

The font that I use in my terminal is exactly the same font that I use in Emacs, so I really don't know what's going on here. The settings for the shell layer are pretty normal:

(shell :variables
       shell-default-shell 'multi-term
       ;; that's where the screenshot is from, but
       ;; the problem occurs with term and ansi-term as well.
       shell-default-position 'bottom
       shell-default-height 30)

And, as I mentioned in the title, I'm using fish.

I would love to provide more details, but I don't really know what details are relevant in this situation, being very much a noob. I would really appreciate some help if someone's encountered the same situation.

Thanks a lot in advance!

1

It looks like your font is fine, (some of) the special glyphs show up as expected. It's the colour that's broken. The following settings should sort out the colour:

(add-to-list 'comint-output-filter-functions 'ansi-color-process-output)
(ansi-color-for-comint-mode-on)

With this config, the Hack font, and an appropriate definition of $PS1 I have the following prompt in shell-mode:

enter image description here

Warning!

Using a spectacular prompt like this will cause problems with modes that need to be able to detect your prompt. Notably, this includes Tramp (i.e., see Tramp using su fails with powerline prompt) and org-babel. You'll need to update a few other variables to avoid this.

For my config, this includes the following:

Fancy prompt defined in ~/.emacs.d/init_bash.sh:

  export PS1="\[\e[36;40m\]\[\e[31;46m\]\D{%x} \A\[\e[36;42m\]\[\e[30;42m\]\w\[\e[32;41m\]\$(exitstatus)\$(jobscount)\[\e[0;32m\]\[\e[m\] "
  export PS2="\[\e[0;32m\]❱ \[\e[m\]"

Adding the special glyphs to the comint prompt regexp (which I do in my shell-mode-hook):

(defun tws-shell-mode-hook ()
  ...
  (setq comint-prompt-regexp "\\(?:^\\|
\\)[^]#$%>
]*#?[]#$%>❱] *\\(\\[[0-9;]*[a-zA-Z] *\\)*")
  ...)

(add-hook 'shell-mode-hook 'tws-shell-mode-hook)

You also need to add the glyphs to tramp-shell-mode-hook, which I've done vis the customization interface (you could just as easily use (setq ...) in init.el):

(tramp-shell-prompt-pattern
   "\\(?:^\\|
\\)[^]#$%>
]*#?[]#$%>❱] *\\(\\[[0-9;]*[a-zA-Z] *\\)*" nil (tramp))

The specific details will depend on what glyphs you've used in your prompt, so you'll have to play around with the above for your own situation. The sorts of problems you can expect without this configuration include Tramp failing to read your root password, and spewing garbage when you try to use it; and in org-mode, when you evaluate a bash code block, any code that would cause bash to respond with a prompt (e.g., a multi-line for loop) will cause Emacs to hang while babel waits for a recognizable prompt to appear.

  • (add-to-list 'comint-output-filter-functions 'ansi-color-process-output) (ansi-color-for-comint-mode-on) This worked for me... I had some extrange simbols whenever I send a command to the shell. Thanks – user1330614 Oct 7 at 17:04
0

Not every emacs/spacemacs theme provides terminal background colors, I've noticed. You can either:

  1. use a different theme that supports background colors
  2. edit your $PS1 environment variable so that it doesn't use background color. (You can probably even write a tiny if statement in your fishrc to change this only when you're in emacs.)
  3. edit your theme so that it handles background colors correctly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.