mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-16 00:28:10 +02:00
Change the way the working directory for new processes is discovered. If
default-path isn't empty, it is used. Otherwise: 1) If tmux neww is run from the command line, the working directory of the client is used. 2) Otherwise use some platform specific code to retrieve the current working directory of the process in the active pane. 3) If that fails, the directory where the session was created is used. Idea and support code, Linux, Solaris, FreeBSD bits by Romain Francoise, OpenBSD bits by me.
This commit is contained in:
25
cmd.c
25
cmd.c
@ -1212,3 +1212,28 @@ cmd_template_replace(char *template, const char *s, int idx)
|
||||
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/* Return the default path for a new pane. */
|
||||
char *
|
||||
cmd_get_default_path(struct cmd_ctx *ctx)
|
||||
{
|
||||
char *cwd;
|
||||
struct session *s;
|
||||
struct window_pane *wp;
|
||||
|
||||
if ((s = cmd_current_session(ctx, 0)) == NULL)
|
||||
return (NULL);
|
||||
|
||||
cwd = options_get_string(&s->options, "default-path");
|
||||
if (*cwd == '\0') {
|
||||
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
||||
return (ctx->cmdclient->cwd);
|
||||
if (ctx->curclient != NULL) {
|
||||
wp = s->curw->window->active;
|
||||
if ((cwd = osdep_get_cwd(wp->pid)) != NULL)
|
||||
return (cwd);
|
||||
}
|
||||
return (s->cwd);
|
||||
}
|
||||
return (cwd);
|
||||
}
|
||||
|
Reference in New Issue
Block a user