mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
Merge pull request #726 from dequis/term-environment-check
Add a startup warning if the TERM var is wrong inside tmux/screen
This commit is contained in:
commit
2e0815bfd7
@ -207,6 +207,8 @@ static void textui_finish_init(void)
|
||||
fe_settings_set_print("nick");
|
||||
if (user_settings_changed & USER_SETTINGS_HOSTNAME)
|
||||
fe_settings_set_print("hostname");
|
||||
|
||||
term_environment_check();
|
||||
}
|
||||
|
||||
static void textui_deinit(void)
|
||||
|
@ -733,3 +733,31 @@ void term_gets(GArray *buffer, int *line_count)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const char* term_env_warning =
|
||||
"You seem to be running Irssi inside %2$s, but the TERM environment variable "
|
||||
"is set to '%1$s', which can cause display glitches.\n"
|
||||
"Consider changing TERM to '%2$s' or '%2$s-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);
|
||||
}
|
||||
|
@ -105,4 +105,6 @@ void term_gets(GArray *buffer, int *line_count);
|
||||
void term_common_init(void);
|
||||
void term_common_deinit(void);
|
||||
|
||||
void term_environment_check(void);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user