powerlevel9k icon indicating copy to clipboard operation
powerlevel9k copied to clipboard

TERM="xterm-256color" not recognized anymore on FreeBSD

Open hsiktas opened this issue 7 years ago • 12 comments

Describe Your Issue

What is happening?

After updating the theme from 0e3c192 to b16c0d5 I get the warning message that my terminal does not support 256 colors and that I should set export TERM="xterm-256color" at the top of my ~/.zshrc. I did also update to b16c0d5 on my nearly identical Ubuntu (WSL), macOS and Termux setups and they don't show this message. Is happens as soon as I ssh into my FreeBSD server and the used terminal emulator does not seem to matter here.

Have you tried to debug or fix it?

I already added export TERM="xterm-256color" to my ~/.zshrc and it is set according to echo $TERM. Even running something like fortune | lolcat shows that 256 colors are working. The presence of the warning message seems to be an error. 🤔

Environment Information

This information will help us understand your configuration.

  • What version of ZSH are you using? You can use zsh --version to see this.
    • zsh 5.6.2 (amd64-portbld-freebsd11.2)
  • Do you use a ZSH framework (e.g., Oh-My-ZSH, Antigen)?
    • Oh My Zsh
  • How did you install P9k (cloning the repo, by tarball, a package from your OS, etc.,)?
    • cloning the repo into ~/.oh-my-zsh/custom/themes
  • What version of P9k are you using?
    • b16c0d5
  • Which terminal emulator do you use?
    • iTerm2, mintty, Termux

hsiktas avatar Oct 10 '18 16:10 hsiktas

I'm having the same problem with FreeBSD as well. The problem looks to be that termColors() (in functions/colors.zsh) uses 'tput colors' to get the colour capability of the terminal. Except that under FreeBSD, this seems to be returning the value for the number of columns instead. I do note that the alternative method (if tput doesn't exist) - $(echotc Co) - does return the correct number of colours available.

Anyway, all that this termColors function seems to do is just print out a warning if the terminal doesn't support 256 colours. It doesn't seem to set anything (other than a variable local to that function).

So putting in POWERLEVEL9K_IGNORE_TERM_COLORS=true into .zshrc seems to suppress that warning.

tseatah avatar Oct 12 '18 13:10 tseatah

Hi,

Same problem here and the POWERLEVEL9K_IGNORE_TERM_COLORS=true solve the warning but I added some custom icons for my OS and branch: POWERLEVEL9K_FREEBSD_ICON=$'\uF3A4' POWERLEVEL9K_VCS_BRANCH_ICON=$'\uF126

and there replaced by a question mark until I run source .zshrc then the icons are correct.

The background and segments are ok before the source command, just the icons are missing.

Any idea about what going wrong?

  • FreeBSD 11.2-RELEASE-p4
  • zsh 5.6.2 (amd64-portbld-freebsd11.2)
  • version of p9k: ad14807cef372994c3ba00632117f6d43b798ffb
  • Terminal used: mate-terminal, terminator

jfoucry avatar Oct 22 '18 15:10 jfoucry

You should always do custom settings before sourcing the theme. Check the Wiki for reference

onaforeignshore avatar Oct 22 '18 19:10 onaforeignshore

That what I do. I source the theme after choosing my plugins and before sourcing .oh-my-zshrc/oh-my-zsh.sh script.

`TERM="xterm-256color" export TERM POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon context dir vcs) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator history) POWERLEVEL9K_MODE='awesome-fontconfig' POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 POWERLEVEL9K_SHORTEN_DELIMITER="" POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right" POWERLEVEL9K_HIDE_BRANCH_ICON=false POWERLEVEL9K_VCS_BRANCH_ICON=$'\uF126 ' POWERLEVEL9K_FREEBSD_ICON=$'\uF3A4' POWERLEVEL9K_IGNORE_TERM_COLORS=true ZSH=$HOME/.oh-my-zsh source ~/.fonts/*.sh plugins=(git gitfast git-flow sublime svn svn-fast-info colored-man-page colorize zsh-autosuggestions tmux tmuxinator ssh-agent gpg-agent zsh-navigation-tools zsh_reload)

ZSH_THEME="powerlevel9k/powerlevel9k" source $ZSH/oh-my-zsh.sh …`

jfoucry avatar Oct 24 '18 21:10 jfoucry

@jfoucry - Just to make sure I understand, you're saying you have all of that in your .zshrc, and when you start a terminal session P9k is loaded and working EXCEPT for those two icons, and then after you source your .zshrc AGAIN, the icons work?

bhilburn avatar Oct 26 '18 18:10 bhilburn

On 10/26/18 8:02 PM, Ben Hilburn wrote:

@jfoucry - Just to make sure I understand, you're saying you have all of that in your .zshrc, and when you start a terminal session P9k is loaded and working EXCEPT for those two icons, and then after you source your .zshrc AGAIN, the icons work?

That's right.

Juste those two icons does not work until I source again my ~/.zshrc.

Jacques

jfoucry avatar Oct 26 '18 20:10 jfoucry

@jfoucry - Well, uh, that's pretty weird. What version of P9k are you using? An official release? Can you try the next branch and let us know if it's any different?

bhilburn avatar Oct 27 '18 01:10 bhilburn

On 10/27/18 3:13 AM, Ben Hilburn wrote:

@jfoucry - Well, uh, that's pretty weird. What version of P9k are you using? An official release? Can you try the next branch and let us know if it's any different?

Yes, I use an official release grab with a git clone: commit ad14807cef372994c3ba00632117f6d43b798ffb (HEAD -> master, origin/master, origin/HEAD).

I switched to next branch. after correct my .zshrc (new variable names), it's better and worst at the same time.

Instead of the OS icon, I have the "official p9k BSD icon" which is more an angry smiley with horn than the BSD icon. And the branch icon does not displayed (replaced by a question mark). To be clear, my custom icons are not used.

Here is the begin of my new .zshrc.

`TERM="xterm-256color" export TERM

Path to your oh-my-zsh configuration.

Set name of the theme to load.

Look in ~/.oh-my-zsh/themes/

Optionally, if you st this to "random", it'll load a random theme each

time that oh-my-zsh is loaded.

Theme customisation

P9K_LEFT_PROMPT_ELEMENTS=(os_icon context dir vcs) P9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator history) P9K_MODE='awesome-fontconfig' P9K_DIR_SHORTEN_LENGTH=2 P9K_DIR_SHORTEN_DELIMITER="" P9K_DIR_SHORTEN_STRATEGY="truncate_from_right" P9K_VCS_HIDE_BRANCH_ICON=false P9K_VCS_BRANCH_ICON=$'\uF126 ' P9K_VCS_FREEBSD_ICON=$'\uF3A4' P9K_IGNORE_TERM_COLORS=true ZSH=$HOME/.oh-my-zsh source ~/.fonts/*.sh`

When I launch my terminal (Terminator) I have some errors:

ps: cmd: keyword not found ps: no valid keywords; valid keywords:

Jacques

jfoucry avatar Oct 27 '18 09:10 jfoucry

Okay, I think we should try to figure out those errors you are seeing at the end before debugging other things - if the environment isn't sane, trying to hunt down other problems is difficult.

Can you share the entirety of your zshrc? I'm wondering what might be causing those errors. If you comment out your ZSH_THEME variable to not use P9k, do you still see those errors?

bhilburn avatar Oct 30 '18 13:10 bhilburn

Sorry, I was a little bit busy.

So if I comment out ZSH_THEME I did not have those errors.

Here is my .zshrc file, I just remove aliases with password.

TERM="xterm-256color"
export TERM
# Path to your oh-my-zsh configuration.

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you st this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
# Theme customisation
P9K_LEFT_PROMPT_ELEMENTS=(os_icon context dir vcs)
P9K_RIGHT_PROMPT_ELEMENTS=(status history)
P9K_MODE='awesome-fontconfig'
P9K_DIR_SHORTEN_LENGTH=2
P9K_DIR_SHORTEN_DELIMITER=""
P9K_DIR_SHORTEN_STRATEGY="truncate_from_right"
P9K_VCS_HIDE_BRANCH_ICON=false
P9K_VCS_BRANCH_ICON=$'\uF126 '
#P9K_VCS_FREEBSD_ICON=$''
P9K_VCS_FREEBSD_ICON=$'\uF3A4'
P9K_IGNORE_TERM_COLORS=true
ZSH=$HOME/.oh-my-zsh
source ~/.fonts/*.sh
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"

# Comment this out to disable weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"

# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"

# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git gitfast git-flow sublime svn svn-fast-info colored-man-page colorize zsh-autosuggestions terminator tmux tmuxinator ssh-agent gpg-agent zsh-navigation-tools zsh_reload)

ZSH_THEME="powerlevel9k/powerlevel9k"
source $ZSH/oh-my-zsh.sh

DEFAULT_USER="jacques"
# Customize to your needs...
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:$HOME/.local/bin

export SOURCE=~/Documents/Sources
export EP="${SOURCE}"/Exodus-privacy

alias gvim="gvim -p"

if [ $(uname -o) = "FreeBSD" ]
	then
	alias ls="ls -G"
else
	alias ls="ls --color=auto"
fi

alias ll='ls -al'
alias rtl='ls -rtla'

alias epoch="echo $(($(date +%s) / 60 / 60 / 24))"

export JAVA_HOME="/usr/local/openjdk7"
# export JAVA_HOME="${HOME}/Android/android-studio/jre"
export PYTHONPATH=/usr/local/ansible/lib
export MANPATH=$MANPATH:/usr/local/ansible/docs/man
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/Android/android-studio/jre:/usr/local/lib


setopt promptsubst
autoload -Uz vcs_info

zstyle ':vcs_info:*' enable git svn hg
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr '✚'
zstyle ':vcs_info:*' unstagedstr '●'
zstyle ':vcs_info:*' formats ' %u%c%b'
zstyle ':vcs_info:*' actionformats ' %u%c'  
vcs_info
echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
precmd() {  # run before each prompt
  vcs_info
}
# Complétion 
autoload -U compinit
compinit


zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin \
                             /usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin
# Crée un cache des complétion possibles
# très utile pour les complétion qui demandent beaucoup de temps
# comme la recherche d'un paquet aptitude install moz<tab>
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh_cache
# des couleurs pour la complétion
# faites un kill -9 <tab><tab> pour voir :)
zmodload zsh/complist
setopt extendedglob
zstyle ':completion:*:*:kill:*:processes' list-colors "=(#b) #([0-9]#)*=36=31"

zstyle ':omz:plugins:ssh-agent' agent-forwarding
zstyle ':omz:plugins:ssh-agent' identities id_ecdsa
# Start or restart daemon keyring
# export `gnome-keyring-daemon`

export myip=$(dig +short myip.opendns.com @resolver1.opendns.com)

# source /usr/local/sge/default/common/settings.sh
# alias qstat="qstat -f -u \"*\""

#
# setup ssh-agent
#


# set environment variables if user's agent already exists
[ -z "$SSH_AUTH_SOCK" ] && SSH_AUTH_SOCK=$(ls -l /tmp/ssh-*/agent.* 2> /dev/null | grep $(whoami) | awk '{print $9}')
[ -z "$SSH_AGENT_PID" -a -z `echo $SSH_AUTH_SOCK | cut -d. -f2` ] && SSH_AGENT_PID=$((`echo $SSH_AUTH_SOCK | cut -d. -f2` + 1))
[ -n "$SSH_AUTH_SOCK" ] && export SSH_AUTH_SOCK
[ -n "$SSH_AGENT_PID" ] && export SSH_AGENT_PID

# start agent if necessary
if [ -z $SSH_AGENT_PID ] && [ -z $SSH_TTY ]; then  # if no agent & not in ssh
  eval `ssh-agent -s` > /dev/null
fi

# setup addition of keys when needed
if [ -z "$SSH_TTY" ] ; then                     # if not using ssh
  ssh-add -l > /dev/null                        # check for keys
  if [ $? -ne 0 ] ; then
    alias ssh='ssh-add -l > /dev/null || ssh-add && unalias ssh ; ssh'
    if [ -f "/usr/lib/ssh/x11-ssh-askpass" ] ; then
      SSH_ASKPASS="/usr/lib/ssh/x11-ssh-askpass" ; export SSH_ASKPASS
    fi
  fi
fi

#[ -z "$SSH_AUTH_SOCK" ] && eval "$(ssh-agent)"

export ANDROID_HOME=/usr/home/jacques/Android/android-sdk-linux

PATH="/usr/home/jacques/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/usr/home/jacques/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/usr/home/jacques/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/usr/home/jacques/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/usr/home/jacques/perl5"; export PERL_MM_OPT;


alias WPA="/usr/sbin/wpa_supplicant -Dbsd -iwlan0 -c/etc/wpa_supplicant.conf"
alias clone="/usr/local/bin/rclone sync -v  ~/Documents/NextCloud/ nextcloud"

jfoucry avatar Nov 02 '18 18:11 jfoucry

Due to this post:

there is no termcap capability named colors, so tput colors seems to output the nearest equivalent, which is co, the number of columns.

In my freenas jails, tput colors equals to tput co equals to 130 (which is my columns). tput Co gives 256.

But, the Co terminfo doesn't exists at my MacBook:

tput Co
tput: unknown terminfo capability 'Co'

So, maybe we have to detect OS type?

thawk avatar Jun 27 '19 13:06 thawk

I am using zsh as my shell with ohmyzsh and powerlevel9k. It complains that my terminal appears to support fewer than 256 colors and 'export TERM="xterm-256color" to the .zshrc. I set it on the top of the zshrc file but I still get the warning. when I check with tput colors, it says 80 . If I change the size of the terminal the value changes for the command tput colors.

This information will help us understand your configuration.

  • What version of ZSH are you using -> zsh 5.8 (am d64-portbld-freebsd12.1)

  • Do you use a ZSH framework -> Oh-My-ZSH

  • How did you install P9k -> Git clone as specified on the GitHub main page

  • What version of P9k are you using? -> latest from github

  • Which terminal emulator do you use? -> Tested with the default terminal on FreeBSD and Alacritty.

sajusat avatar Apr 05 '20 12:04 sajusat