1

My main setup uses zsh and prezto on Mac OS with a custom prompt theme (I use iTerm2 and not Terminal.app).

I was wondering what's the best way to have a similar experience with an Emacs terminal emulator.

I seems that the answer is easy: M-x ansi-term (or just M-x term ?)

However the prompt is not very nice as Emacs doesn't understand the special character my theme uses (some kind of fat arrow).

How could I fix this? Can I 'detect' in my zshrc file that I'm inside Emacs and change the prompt?

3
  • Do you have (set-terminal-coding-system 'utf-8-unix) in your init file?
    – Nsukami _
    Nov 18, 2015 at 14:02
  • I didn't but now I do and it didn't change.
    – Cedric H.
    Nov 18, 2015 at 14:22
  • 1
    You can use the INSIDE_EMACS environment variable. The value varies contextually (it is different in a M-x shell buffer than it is in a M-x term buffer), so you can also make more granular decisions if need be.
    – phils
    Apr 3, 2018 at 5:26

1 Answer 1

1

M-x ansi-term (and M-x term by the way) sets the TERM environment variable to eterm-color, so that's something you can use to adjust the prompt in you .zshrc

I have something similar in my prezto setup (although for dumb terminal, which is even more limited):

# Disable color and theme in dumb terminals.
if [[ "$TERM" == 'dumb' ]]; then
  zstyle ':prezto:*:*' color 'no'
  zstyle ':prezto:module:prompt' theme 'off'
fi

You might want something more subtle in your case !

1
  • Thanks, that's what I was looking for. It seems also that prezto automatically switches the prompt off when the terminal is dumb.
    – Cedric H.
    Nov 22, 2015 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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