Add a startup warning if the TERM var is wrong inside tmux/screen

One of the most common and confusing issues we get in #irssi,
this should help identifying and mitigating it.
This commit is contained in:
dequis 2017-06-23 21:53:16 -03:00
commit 0aafd011c0
3 changed files with 32 additions and 0 deletions

View file

@ -733,3 +733,31 @@ void term_gets(GArray *buffer, int *line_count)
}
}
}
static const char* term_env_warning =
"The TERM environment variable is set to '%s' which can cause display "
"glitches when running under %s.\n"
"Consider changing TERM to 'screen' or 'screen-256color' instead.";
void term_environment_check(void)
{
const char *term, *sty, *tmux, *multiplexer;
term = g_getenv("TERM");
sty = g_getenv("STY");
tmux = g_getenv("TMUX");
multiplexer = (sty && *sty) ? "screen" :
(tmux && *tmux) ? "tmux" : NULL;
if (!multiplexer) {
return;
}
if (term && (g_str_has_prefix(term, "screen") ||
g_str_has_prefix(term, "tmux"))) {
return;
}
g_warning(term_env_warning, term, multiplexer);
}