aboutsummaryrefslogtreecommitdiff
path: root/environ.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2017-03-09 22:21:29 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2017-03-09 22:21:29 +0000
commit385a361bf86f95ab40716e58cf364006a5e921d0 (patch)
treeda66d9ed6f6f37e10d8107bc4d81b588f1f0425e /environ.c
parenta24cf4a5e1a6a7309649e5bc11a9d8f9d0cc241b (diff)
parentc5bdae466e4dad6c185fa5146b11275b6119ff24 (diff)
downloadrtmux-385a361bf86f95ab40716e58cf364006a5e921d0.tar.gz
rtmux-385a361bf86f95ab40716e58cf364006a5e921d0.tar.bz2
rtmux-385a361bf86f95ab40716e58cf364006a5e921d0.zip
Merge branch 'master' of github.com:tmux/tmux
Diffstat (limited to 'environ.c')
-rw-r--r--environ.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/environ.c b/environ.c
index 4bb794dd..868324ed 100644
--- a/environ.c
+++ b/environ.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "tmux.h"
@@ -218,3 +219,28 @@ environ_log(struct environ *env, const char *prefix)
}
}
}
+
+/* Create initial environment for new child. */
+struct environ *
+environ_for_session(struct session *s)
+{
+ struct environ *env;
+ const char *value;
+ int idx;
+
+ env = environ_create();
+ environ_copy(global_environ, env);
+ if (s != NULL)
+ environ_copy(s->environ, env);
+
+ value = options_get_string(global_options, "default-terminal");
+ environ_set(env, "TERM", "%s", value);
+
+ if (s != NULL)
+ idx = s->id;
+ else
+ idx = -1;
+ environ_set(env, "TMUX", "%s,%ld,%d", socket_path, (long)getpid(), idx);
+
+ return (env);
+}