diff --git a/environ.c b/environ.c index 5abf383c..fb1c4902 100644 --- a/environ.c +++ b/environ.c @@ -262,6 +262,12 @@ environ_for_session(struct session *s, int no_TERM) environ_set(env, "TERM", 0, "%s", value); environ_set(env, "TERM_PROGRAM", 0, "%s", "tmux"); environ_set(env, "TERM_PROGRAM_VERSION", 0, "%s", getversion()); + environ_set(env, "COLORTERM", 0, "truecolor"); + } else { + environ_unset(env, "TERM"); + environ_unset(env, "TERM_PROGRAM"); + environ_unset(env, "TERM_PROGRAM_VERSION"); + environ_unset(env, "COLORTERM"); } if (s != NULL) diff --git a/tty-term.c b/tty-term.c index 460b761f..b6b0dfce 100644 --- a/tty-term.c +++ b/tty-term.c @@ -532,6 +532,7 @@ tty_term_create(struct tty *tty, char *name, char **caps, u_int ncaps, size_t offset, namelen; char *first; int n; + struct environ_entry *envent; log_debug("adding term %s", name); @@ -595,6 +596,17 @@ tty_term_create(struct tty *tty, char *name, char **caps, u_int ncaps, a = options_array_next(a); } + /* Check for COLORTERM. */ + envent = environ_find(tty->client->environ, "COLORTERM"); + if (envent != NULL) { + log_debug("%s COLORTERM=%s", tty->client->name, envent->value); + if (strcasecmp(envent->value, "truecolor") == 0 || + strcasecmp(envent->value, "24bit") == 0) + tty_add_features(feat, "RGB", ","); + else if (strstr(s, "256") != NULL) + tty_add_features(feat, "256", ","); + } + /* Apply overrides so any capabilities used for features are changed. */ tty_term_apply_overrides(term);