aboutsummaryrefslogtreecommitdiff
path: root/cmd-new-session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-06-27 02:56:59 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-06-27 02:56:59 +0000
commit07a71fd432df5873515da82d2d620ec0d986b558 (patch)
treea4a9064b09cfc31f1ec1f49adb7e1f7b8308eaed /cmd-new-session.c
parent26524c99f68959b5a0d1698529f332934061d424 (diff)
downloadrtmux-07a71fd432df5873515da82d2d620ec0d986b558.tar.gz
rtmux-07a71fd432df5873515da82d2d620ec0d986b558.tar.bz2
rtmux-07a71fd432df5873515da82d2d620ec0d986b558.zip
Store the current working directory in the session, change the default-path
option to default to empty and make that mean that the stored session CWD is used.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r--cmd-new-session.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c
index 5e175bea..290d5a3b 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -18,8 +18,10 @@
#include <sys/types.h>
+#include <pwd.h>
#include <string.h>
#include <termios.h>
+#include <unistd.h>
#include "tmux.h"
@@ -125,8 +127,9 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
struct window_pane *wp;
struct environ env;
struct termios tio, *tiop;
- const char *update;
- char *overrides, *cmd, *cwd, *cause;
+ struct passwd *pw;
+ const char *update, *cwd;
+ char *overrides, *cmd, *cause;
int detached, idx;
u_int sx, sy, i;
@@ -198,8 +201,13 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
/* Get the new session working directory. */
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
cwd = ctx->cmdclient->cwd;
- else
- cwd = options_get_string(&global_s_options, "default-path");
+ else {
+ pw = getpwuid(getuid());
+ if (pw->pw_dir != NULL && *pw->pw_dir != '\0')
+ cwd = pw->pw_dir;
+ else
+ cwd = "/";
+ }
/* Find new session size. */
if (detached) {