ZSH and fbterm in TTY

I am so close to figuring this out, that I can taste it, but there is one thing which continually teases me, and that is fbterm’s TERM setting.

So right; I am using zsh as my shell. Everywhere. It’s even set as login shell. I am also using PowerLevel9K as my theme, which is a Powerline-alike that is super-functional, so I have a fancy and blinged-out terminal with the colours and settings I want. And I want it to work in a TTY. So here’s the problems I encountered and how I resolved prior ones thus far;

  • PL9K complains abbout lack f 256-colour support
  • Resolution: Do what the theme says and set zsh to use xterm-256colors in my .zshrc file
  • fbterm doesn’t function without sudo
  • Resolution: Add myself to video group with gpasswd; reboot
  • fbterm isn’t the first thing that shows when I sign in via TTY
  • Resolution: Add this to my .zlogin file.
  • fbterm doesn’t load with 256-color support
  • Resolution: Yet to be determined.

So that is where I am at. The solution seems simple; tell fbterm to use fbterm as TERM, but when I put in code to do that, it ends up doing nothing of significance; when I do echo $TERM I get xterm-256colors still instead of fbterm as output. So now here’s the question, with all of that setup in mind;

How do I change it so after logging into a TTY, TERM is set to fbterm instead of xterm-256colors?

Are you sure you are using .zprofile instead of .zshrc for your login shell preferences?

Alternatively…

# .zprofile
if [ -f ~/.zshrc ]; then
   source ~/.zshrc
fi

Or you can try also .zlogin, which is read last on login shells.

1 Like

Try this:

#### BEGIN: Zsh Powerlevel10k support for Linux consoles
# So our 'powerlevel10k' zsh prompt is pretty hideous from the Linux console.
# Lack of font and 256 colour support for special characters it is using.
# 'fbterm' can give us a framebuffer terminal to overcome this:

# Start fbterm automatically in /dev/tty*:
# Detect if 'fbterm' command is installed.
# If so, check if we logged in on the console
# devices (/dev/tty[1-9]).
# If so, kick off 'fbterm' with one of the Nerd Font patched TrueType fonts.
# Set the terminal type to "fbterm", instead of the default of "linux" to
# enable 256 colour mode.
# sudo #1 is because fbterm requires root
# sudo #2 is to change us back to ourselves.
# Make sure your /etc/sudoers is set accordingly to enable this.
# Requires patch font installed in /usr/share/fonts/truetype/,
# for me, I used the MesloLGS NF family of ttf fonts, installed
# to /usr/share/fonts/truetype/nerdfont.  Use 'fc-cache' to update
# the font cache.
if (( ${+commands[fbterm]} )); then
  if [[ "$TTY" = /dev/tty* ]] ; then
    sudo fbterm -n "MesloLGS NF" -s 20 -- sudo -i -u $USER TERM=fbterm && exit
  fi
fi

# Now we're likely being run again (this .zlogin script), as you just sudo'd
# back to yourself.  If that's true, your terminal type should be "fbterm".
# If so, re-display the dynamic MOTD... as it showed only for a moment and
# blinked away when switching from linux console to 'fbterm':
if [ "${TERM}" = "fbterm" -a -f "/run/motd.dynamic" ]; then
  cat /run/motd.dynamic
fi

#### END: Zsh Powerlevel10k support for Linux consoles