From e2d59a6c1713cdb18f0a96ad9da9eac11fa60d88 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Fri, 30 Dec 2011 14:21:02 +0000 Subject: [PATCH] Sync OpenBSD patchset 993: Allow $HOME as default-path in tmux.conf so the same config file can be used on different machines regardless of where the user's home directory is. ok nicm --- cmd.c | 7 +++++++ tmux.1 | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/cmd.c b/cmd.c index aee095e6..85ae1dd2 100644 --- a/cmd.c +++ b/cmd.c @@ -1220,11 +1220,18 @@ cmd_get_default_path(struct cmd_ctx *ctx) char *cwd; struct session *s; struct window_pane *wp; + struct environ_entry *envent; if ((s = cmd_current_session(ctx, 0)) == NULL) return (NULL); cwd = options_get_string(&s->options, "default-path"); + if ((cwd[0] == '~' && cwd[1] == '\0') || !strcmp(cwd, "$HOME")) { + envent = environ_find(&global_environ, "HOME"); + if (envent != NULL && *envent->value != '\0') + return envent->value; + cwd = ""; + } if (*cwd == '\0') { if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL) return (ctx->cmdclient->cwd); diff --git a/tmux.1 b/tmux.1 index d02f0a77..3349737f 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1849,6 +1849,11 @@ Set the default working directory for new panes. If empty (the default), the working directory is determined from the process running in the active pane, from the command line environment or from the working directory where the session was created. +If +.Ar path +is "$HOME" or "~", the value of the +.Ev HOME +environment variable is used. .It Ic default-shell Ar path Specify the default shell. This is used as the login shell for new windows when the