dieggsy / eterm-256color

Customizable 256 colors for emacs term and ansi-term
GNU General Public License v3.0
69 stars 3 forks source link

zsh warning #4

Closed YujiShen closed 6 years ago

YujiShen commented 6 years ago

After did all steps, I can get colors working, but I got warning every time I enter some command:

% ls
zle-line-finish:echoti:1: no such terminfo capability: rmkx
.....
%                                                                                                                                         
zle-line-init:echoti:1: no such terminfo capability: smkx

I am on macOS, using spacemacs. Did some search but I don't know what this is.

dieggsy commented 6 years ago

Huh, zsh was my main shell up until like a week ago and I never experienced this issue, can I know more about your zsh config? Or do you get this error with zsh --no-rcs as well?

YujiShen commented 6 years ago

With zsh --no-rcs there is no error, but no color as well...

Make sure TERM really gets set to eterm-256color. It may be overridden if you export TERM in any of your shell init files

I found after I comment export TERM=eterm-256color in my Emacs condition under .zshrc, the warning disappear and the color also works. But I did export TERM=xterm-256color in .zshenv. And I echo $TERM will got xterm-256color.

Here is my .zshrc:

# load antigen
source /usr/local/share/antigen/antigen.zsh

# Load the oh-my-zsh's library.
antigen use oh-my-zsh

# Bundles from the default repo (robbyrussell's oh-my-zsh).
antigen bundle git
antigen bundle heroku
antigen bundle pip
antigen bundle lein
antigen bundle command-not-found

# Syntax highlighting bundle.
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-autosuggestions

# Load the theme.
antigen theme miekg/lean

# Tell Antigen that you're done.
antigen apply

if [[ -n "$EMACS" ]]; then
    #export TERM=eterm-256color
    alias emacs="emacsclient --no-wait"
    export EDITOR="emacsclient --no-wait"
    export VISUAL="emacsclient"
fi

And here is my .zshenv:

export PATH="/usr/local/bin:/usr/bin:/usr/local/sbin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin:/usr/local/opt/go/libexec/bin:/Users/Yuji/.go/bin:/usr/local/opt/coreutils/libexec/gnubin:~/.rbenv/shims"

# Make GNU command default to man
export MANPATH="/usr/local/opt/coreutils/libexec/gnuman:/usr/local/share/centos_man:/usr/local/share/linux-man-pages:$MANPATH"

export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export TERM=xterm-256color

# Python
export PYTHONIOENCODING=utf-8

# *env
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
eval "$(rbenv init -)"
eval "$(jenv init -)"

# Dircolors
eval `gdircolors ~/.dir_colors`
alias ls='gls --color=auto'

# don't check for new mail
MAILCHECK=0

I am a newbie about this, if there is anything wrong, feel free to correct me. Thanks!

dieggsy commented 6 years ago

@YujiShen Hmm, I see you're using some plugins from oh-my-zsh - on quickly checking I think there are some zsh-specific settings set in those that depend on the term type (but they check first if I recall correctly). I have two suggestions. The first is to try putting this block:

if [[ -n "$EMACS" ]]; then
    export TERM=eterm-256color
    alias emacs="emacsclient --no-wait"
    export EDITOR="emacsclient --no-wait"
    export VISUAL="emacsclient"
fi

At the top instead of the bottom of your .zshrc and let me know what happens. (Note the export TERM is uncommented)

The second thing I'd say to try is to not export TERM at all (in neither zshrc or zshenv) when inside emacs. This is what I was doing, and it seemed to be working fine for me:

# I guess you're doing this with the EMACS 
# environment variable instead so try using that
[ -z $INSIDE_EMACS ] && export TERM=xterm-256color

An aside:

To be honest, I need to more closely investigate the effect of using xterm-256color instead of eterm-256color. The reason I made eterm-256color is because shell syntax highlighting and fish-like autosuggestions (in either zsh or fish) were producing some weird behavior with xterm-256color that was fixed by just tweaking Emacs's eterm-color to produce eterm-256color (I think there were a couple other things, but I can't quite remember). I guess if xterm-256color is sufficient for some people, I could add a note about that in the README.

dieggsy commented 6 years ago

To be clear, one of my suggestions is not setting TERM at all because (unless I'm mistaken about what some of my code is doing), the minor-mode takes care of that (that is, setting it to eterm-256color) unless you override it yourself.

YujiShen commented 6 years ago

Thanks for your help!

  1. I move the Emacs block up to top, and the warning disappear!

  2. Then I comment all TERM settings, it works perfectly, but the color are different under Emacs and iTerm. I guess this is caused by the dircolors showing different colors under eterm and xterm.

I tried xterm-256color package before, but I don't know how to config it. After installing I still can not get colors I want, so I gave it up... Thanks for your package and suggestions!

I found your package also works for multi-term.

dieggsy commented 6 years ago

Glad I could help!

This package actually uses the xterm-color package to generate colors. That package did not support term-mode, so my package basically adds term-mode support to xterm-color (or, adds 256color support to term-mode, however you like 😄 ).

With regard to the colors looking different, you should be able to customize all colors in eterm-256color to match your colors in iTerm, see: https://github.com/dieggsy/eterm-256color#customization. Note that for the first 16 colors you can either customize faces directly or customize xterm-color-names and xterm-color-names-bright (which is probably preferrable for consistency with other modes that xterm-color supports). I'm not sure why dircolors would be different under eterm and xterm as I think it's the same for me.

And I'm fairly certain multi-term (and sane-term, a similar variant that I like) are basically convenience wrappers for term/ansi-term, so it makes sense eterm-256color would work for those as well.