Skip to content

Instantly share code, notes, and snippets.

@hakerdefo
Last active September 19, 2021 03:37
Show Gist options
  • Save hakerdefo/694a71c402f5966fe7b54018854f0e75 to your computer and use it in GitHub Desktop.
Save hakerdefo/694a71c402f5966fe7b54018854f0e75 to your computer and use it in GitHub Desktop.
Make Byobu's F-keys keybindings work in virtual console (TTY).

Byobu's F-keys keybindings were not working for me in virtual console a.k.a TTY. However, the Byobu F-keys keybindings were working fine in X Window terminals (LXTerminal, Sakura, Terminology, Xfce-Terminal) under X-Window-System. It was perplexing. 'byobu-keybindings' script written by Byobu author Dustin Kirkland to check the Byobu keybindings was giving me "Byobu keybindings: [ON]" message but F-keys were failing me in virtual console (TTY). Very perplexing indeed, mysterious even. I changed Byobu backend from tmux to screen and back but alas no joy. Google and DuckDuckGo also decided to left me high & dry this time. So it was time for soul-searching and man-page reading. After traveling through a gazillion man-pages, wrestling with escape codes & sequences, here, ladies & gentlemen is the holy grail.

If you use Bash as your login shell, add following code to your ~/.bashrc or /etc/bashrc or /etc/bash.bashrc

shopt -q login_shell
RETVAL=$?
if [[ "$RETVAL" == 0 ]] ; then
export TERM='linux'
else
export TERM='xterm-256color'
fi

If you don't use Bash as the log in shell but instead use some other "sh compatible" shell, add following code to the configuration file (.cshrc, .kshrc, .tcshrc, .zshrc, .etc) of your log in shell. This will work fine for Bash as well.

tty="$(tty)"
if test "${tty%%[1-64]*}" = "/dev/tty" ; then
export TERM='linux'
else
export TERM='xterm-256color'
fi

Cheers!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment