=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd.c,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- src/usr.bin/tmux/cmd.c 2011/06/05 11:19:03 1.56 +++ src/usr.bin/tmux/cmd.c 2011/12/09 16:28:18 1.57 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.56 2011/06/05 11:19:03 nicm Exp $ */ +/* $OpenBSD: cmd.c,v 1.57 2011/12/09 16:28:18 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1212,4 +1212,29 @@ } 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 = get_proc_cwd(wp->pid)) != NULL) + return (cwd); + } + return (s->cwd); + } + return (cwd); }