aboutsummaryrefslogtreecommitdiff
path: root/cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/cmd.c b/cmd.c
index 2027f75b..aee095e6 100644
--- a/cmd.c
+++ b/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);
+}