aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/pty_process_unix.c
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2020-11-26 14:04:25 -0500
committerGitHub <noreply@github.com>2020-11-26 14:04:25 -0500
commit6af64d384f96a69462a2a50dd7054566af98de37 (patch)
treed43360aa193fbf3aa434218896a9823e04863eb1 /src/nvim/os/pty_process_unix.c
parent10a5f40f9e020c28df471d5380869ac63d8474a7 (diff)
parentd8963c434f01e6a7316fa5a1dad35f95c7ca73b7 (diff)
downloadrneovim-6af64d384f96a69462a2a50dd7054566af98de37.tar.gz
rneovim-6af64d384f96a69462a2a50dd7054566af98de37.tar.bz2
rneovim-6af64d384f96a69462a2a50dd7054566af98de37.zip
Merge pull request #13315 from ThomasFeher/colorscheme_terminal
Fix colors in terminal by maintaining COLORTERM
Diffstat (limited to 'src/nvim/os/pty_process_unix.c')
-rw-r--r--src/nvim/os/pty_process_unix.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c
index f0bc13783c..4d7d9a45df 100644
--- a/src/nvim/os/pty_process_unix.c
+++ b/src/nvim/os/pty_process_unix.c
@@ -160,8 +160,21 @@ static void init_child(PtyProcess *ptyproc)
os_unsetenv("COLUMNS");
os_unsetenv("LINES");
os_unsetenv("TERMCAP");
- os_unsetenv("COLORTERM");
os_unsetenv("COLORFGBG");
+ // setting COLORTERM to "truecolor" if termguicolors is set and 256
+ // otherwise, but only if it was set in the parent terminal at all
+ if (os_env_exists("COLORTERM")) {
+ const char *colorterm = os_getenv("COLORTERM");
+ if (colorterm != NULL) {
+ if (p_tgc) {
+ os_setenv("COLORTERM", "truecolor", 1);
+ } else {
+ os_setenv("COLORTERM", "256", 1);
+ }
+ } else {
+ os_unsetenv("COLORTERM");
+ }
+ }
signal(SIGCHLD, SIG_DFL);
signal(SIGHUP, SIG_DFL);