Hi,

Attached is a patch which adds support for a TMUX_TMPDIR environment
variable to set the directory for tmux sockets. The TMPDIR variable
isn't acceptable here since it always appends "/tmux-$UID" to the
directory.

My use case is to put all of my sockets into XDG_RUNTIME_DIR. It would
also allow setups with shared tmux usage without having to
remember/alias -S onto all of the commands and without sharing
everything which uses TMPDIR.

Since I'm guessing direct usage of XDG_RUNTIME_DIR (based on previous
discussion about XDG_* environment support) wouldn't be accepted, a more
general way which I can use to put sockets there is acceptable for me.

Thanks,

--Ben
>From 56057f3d7b33f78512d1ec68f37e1d7cb0c32f87 Mon Sep 17 00:00:00 2001
From: Ben Boeckel <maths...@gmail.com>
Date: Tue, 19 Mar 2013 15:05:01 -0400
Subject: [PATCH] Support TMUX_TMPDIR

---
 tmux.1 | 10 ++++++----
 tmux.c |  8 +++++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/tmux.1 b/tmux.1
index bd56044..4062261 100644
--- a/tmux.1
+++ b/tmux.1
@@ -139,11 +139,13 @@ shows any error messages from commands in configuration 
files in the first
 session created, and continues to process the rest of the configuration file.
 .It Fl L Ar socket-name
 .Nm
-stores the server socket in a directory under
-.Pa /tmp
-(or
+stores the server socket in
+.Ev TMUX_TMPDIR
+if set, otherwise in a directory under
 .Ev TMPDIR
-if set);
+(defauting to
+.Pa /tmp
+if unset);
 the default socket is named
 .Em default .
 This option allows a different socket name to be specified, allowing several
diff --git a/tmux.c b/tmux.c
index 4b58aba..32050f7 100644
--- a/tmux.c
+++ b/tmux.c
@@ -167,10 +167,12 @@ makesocketpath(const char *label)
        u_int           uid;
 
        uid = getuid();
-       if ((s = getenv("TMPDIR")) == NULL || *s == '\0')
-               xsnprintf(base, sizeof base, "%s/tmux-%u", _PATH_TMP, uid);
-       else
+       if ((s = getenv("TMUX_TMPDIR")) != NULL && *s != '\0')
+               xsnprintf(base, sizeof base, "%s/", s);
+       else if ((s = getenv("TMPDIR")) != NULL && *s != '\0')
                xsnprintf(base, sizeof base, "%s/tmux-%u", s, uid);
+       else
+               xsnprintf(base, sizeof base, "%s/tmux-%u", _PATH_TMP, uid);
 
        if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST)
                return (NULL);
-- 
1.8.1.4

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to