summaryrefslogtreecommitdiffstats
path: root/cmd.c
diff options
context:
space:
mode:
authorStefan Sperling <stsp@openbsd.org>2011-12-27 14:07:20 +0000
committerStefan Sperling <stsp@openbsd.org>2011-12-27 14:07:20 +0000
commitfdd1d0b72e3aa178653ed8733d4efcb6b14b0c86 (patch)
tree3f150b199021311fa5601a6efa3286429d46f376 /cmd.c
parentd377a68593d354da327db9b15059f94f2306a7e4 (diff)
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
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/cmd.c b/cmd.c
index 6a87f90f..65617a6c 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1221,11 +1221,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);