mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 01:48:47 +00:00
Sync OpenBSD patchset 730:
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.
This commit is contained in:
parent
13e7f060b1
commit
63e76b555d
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-new-session.c,v 1.77 2010-04-05 05:11:43 micahcowan Exp $ */
|
/* $Id: cmd-new-session.c,v 1.78 2010-07-02 02:49:19 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -18,8 +18,10 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <pwd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@ -125,8 +127,9 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct environ env;
|
struct environ env;
|
||||||
struct termios tio, *tiop;
|
struct termios tio, *tiop;
|
||||||
const char *update;
|
struct passwd *pw;
|
||||||
char *overrides, *cmd, *cwd, *cause;
|
const char *update, *cwd;
|
||||||
|
char *overrides, *cmd, *cause;
|
||||||
int detached, idx;
|
int detached, idx;
|
||||||
u_int sx, sy, i;
|
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. */
|
/* Get the new session working directory. */
|
||||||
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
||||||
cwd = ctx->cmdclient->cwd;
|
cwd = ctx->cmdclient->cwd;
|
||||||
|
else {
|
||||||
|
pw = getpwuid(getuid());
|
||||||
|
if (pw->pw_dir != NULL && *pw->pw_dir != '\0')
|
||||||
|
cwd = pw->pw_dir;
|
||||||
else
|
else
|
||||||
cwd = options_get_string(&global_s_options, "default-path");
|
cwd = "/";
|
||||||
|
}
|
||||||
|
|
||||||
/* Find new session size. */
|
/* Find new session size. */
|
||||||
if (detached) {
|
if (detached) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-new-window.c,v 1.46 2010-06-22 23:26:18 tcunha Exp $ */
|
/* $Id: cmd-new-window.c,v 1.47 2010-07-02 02:49:19 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -176,10 +176,13 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cmd = data->cmd;
|
cmd = data->cmd;
|
||||||
if (cmd == NULL)
|
if (cmd == NULL)
|
||||||
cmd = options_get_string(&s->options, "default-command");
|
cmd = options_get_string(&s->options, "default-command");
|
||||||
if (ctx->cmdclient == NULL || ctx->cmdclient->cwd == NULL)
|
|
||||||
cwd = options_get_string(&s->options, "default-path");
|
cwd = options_get_string(&s->options, "default-path");
|
||||||
else
|
if (*cwd == '\0') {
|
||||||
|
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
||||||
cwd = ctx->cmdclient->cwd;
|
cwd = ctx->cmdclient->cwd;
|
||||||
|
else
|
||||||
|
cwd = s->cwd;
|
||||||
|
}
|
||||||
|
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
idx = -1 - options_get_number(&s->options, "base-index");
|
idx = -1 - options_get_number(&s->options, "base-index");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-split-window.c,v 1.34 2010-01-08 16:31:35 tcunha Exp $ */
|
/* $Id: cmd-split-window.c,v 1.35 2010-07-02 02:49:19 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -169,10 +169,13 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cmd = data->cmd;
|
cmd = data->cmd;
|
||||||
if (cmd == NULL)
|
if (cmd == NULL)
|
||||||
cmd = options_get_string(&s->options, "default-command");
|
cmd = options_get_string(&s->options, "default-command");
|
||||||
if (ctx->cmdclient == NULL || ctx->cmdclient->cwd == NULL)
|
|
||||||
cwd = options_get_string(&s->options, "default-path");
|
cwd = options_get_string(&s->options, "default-path");
|
||||||
else
|
if (*cwd == '\0') {
|
||||||
|
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
||||||
cwd = ctx->cmdclient->cwd;
|
cwd = ctx->cmdclient->cwd;
|
||||||
|
else
|
||||||
|
cwd = s->cwd;
|
||||||
|
}
|
||||||
|
|
||||||
type = LAYOUT_TOPBOTTOM;
|
type = LAYOUT_TOPBOTTOM;
|
||||||
if (data->flag_horizontal)
|
if (data->flag_horizontal)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: session.c,v 1.76 2010-06-22 23:26:18 tcunha Exp $ */
|
/* $Id: session.c,v 1.77 2010-07-02 02:49:19 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -67,6 +67,8 @@ session_create(const char *name, const char *cmd, const char *cwd,
|
|||||||
fatal("gettimeofday failed");
|
fatal("gettimeofday failed");
|
||||||
memcpy(&s->activity_time, &s->creation_time, sizeof s->activity_time);
|
memcpy(&s->activity_time, &s->creation_time, sizeof s->activity_time);
|
||||||
|
|
||||||
|
s->cwd = xstrdup(cwd);
|
||||||
|
|
||||||
s->curw = NULL;
|
s->curw = NULL;
|
||||||
TAILQ_INIT(&s->lastw);
|
TAILQ_INIT(&s->lastw);
|
||||||
RB_INIT(&s->windows);
|
RB_INIT(&s->windows);
|
||||||
@ -141,6 +143,7 @@ session_destroy(struct session *s)
|
|||||||
while (!RB_EMPTY(&s->windows))
|
while (!RB_EMPTY(&s->windows))
|
||||||
winlink_remove(&s->windows, RB_ROOT(&s->windows));
|
winlink_remove(&s->windows, RB_ROOT(&s->windows));
|
||||||
|
|
||||||
|
xfree(s->cwd);
|
||||||
xfree(s->name);
|
xfree(s->name);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&dead_sessions); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&dead_sessions); i++) {
|
||||||
|
5
tmux.1
5
tmux.1
@ -1,4 +1,4 @@
|
|||||||
.\" $Id: tmux.1,v 1.261 2010-07-02 02:45:52 tcunha Exp $
|
.\" $Id: tmux.1,v 1.262 2010-07-02 02:49:19 tcunha Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
.\"
|
.\"
|
||||||
@ -1626,7 +1626,8 @@ is used as a login shell.
|
|||||||
.It Ic default-path Ar path
|
.It Ic default-path Ar path
|
||||||
Set the default working directory for processes created from keys, or
|
Set the default working directory for processes created from keys, or
|
||||||
interactively from the prompt.
|
interactively from the prompt.
|
||||||
The default is the current working directory when the server is started.
|
The default is empty, which means to use the working directory of the shell
|
||||||
|
from which the server was started if it is available or the user's home if not.
|
||||||
.It Ic default-terminal Ar terminal
|
.It Ic default-terminal Ar terminal
|
||||||
Set the default terminal for new windows created in this session - the
|
Set the default terminal for new windows created in this session - the
|
||||||
default value of the
|
default value of the
|
||||||
|
14
tmux.c
14
tmux.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.c,v 1.211 2010-07-02 02:45:52 tcunha Exp $ */
|
/* $Id: tmux.c,v 1.212 2010-07-02 02:49:19 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -242,7 +242,7 @@ main(int argc, char **argv)
|
|||||||
struct env_data envdata;
|
struct env_data envdata;
|
||||||
struct msg_command_data cmddata;
|
struct msg_command_data cmddata;
|
||||||
char *s, *shellcmd, *path, *label, *home, *cause;
|
char *s, *shellcmd, *path, *label, *home, *cause;
|
||||||
char cwd[MAXPATHLEN], **var;
|
char **var;
|
||||||
void *buf;
|
void *buf;
|
||||||
size_t len;
|
size_t len;
|
||||||
int opt, flags, quiet = 0, cmdflags = 0;
|
int opt, flags, quiet = 0, cmdflags = 0;
|
||||||
@ -342,6 +342,7 @@ main(int argc, char **argv)
|
|||||||
options_set_number(so, "bell-action", BELL_ANY);
|
options_set_number(so, "bell-action", BELL_ANY);
|
||||||
options_set_number(so, "buffer-limit", 9);
|
options_set_number(so, "buffer-limit", 9);
|
||||||
options_set_string(so, "default-command", "%s", "");
|
options_set_string(so, "default-command", "%s", "");
|
||||||
|
options_set_string(so, "default-path", "%s", "");
|
||||||
options_set_string(so, "default-shell", "%s", getshell());
|
options_set_string(so, "default-shell", "%s", getshell());
|
||||||
options_set_string(so, "default-terminal", "screen");
|
options_set_string(so, "default-terminal", "screen");
|
||||||
options_set_number(so, "detach-on-destroy", 1);
|
options_set_number(so, "detach-on-destroy", 1);
|
||||||
@ -438,15 +439,6 @@ main(int argc, char **argv)
|
|||||||
options_set_number(wo, "utf8", 0);
|
options_set_number(wo, "utf8", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getcwd(cwd, sizeof cwd) == NULL) {
|
|
||||||
pw = getpwuid(getuid());
|
|
||||||
if (pw->pw_dir != NULL && *pw->pw_dir != '\0')
|
|
||||||
strlcpy(cwd, pw->pw_dir, sizeof cwd);
|
|
||||||
else
|
|
||||||
strlcpy(cwd, "/", sizeof cwd);
|
|
||||||
}
|
|
||||||
options_set_string(so, "default-path", "%s", cwd);
|
|
||||||
|
|
||||||
if (cfg_file == NULL) {
|
if (cfg_file == NULL) {
|
||||||
home = getenv("HOME");
|
home = getenv("HOME");
|
||||||
if (home == NULL || *home == '\0') {
|
if (home == NULL || *home == '\0') {
|
||||||
|
3
tmux.h
3
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.565 2010-07-02 02:43:01 tcunha Exp $ */
|
/* $Id: tmux.h,v 1.566 2010-07-02 02:49:19 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -925,6 +925,7 @@ TAILQ_HEAD(session_groups, session_group);
|
|||||||
|
|
||||||
struct session {
|
struct session {
|
||||||
char *name;
|
char *name;
|
||||||
|
char *cwd;
|
||||||
|
|
||||||
struct timeval creation_time;
|
struct timeval creation_time;
|
||||||
struct timeval activity_time;
|
struct timeval activity_time;
|
||||||
|
Loading…
Reference in New Issue
Block a user