summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2011-12-27 14:07:21 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2011-12-27 14:07:21 +0000
commit583c8f7853d62565a1dc43139cf3f3ef7f03300c (patch)
tree2ad54f6724fddf954ad0e943d0953a023f753381
parentf8e5845198aaa8b8e46113d1cf1347f899065ba0 (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
-rw-r--r--usr.bin/tmux/cmd.c9
-rw-r--r--usr.bin/tmux/tmux.19
2 files changed, 15 insertions, 3 deletions
diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c
index f322c8d23f5..5e01699eff3 100644
--- a/usr.bin/tmux/cmd.c
+++ b/usr.bin/tmux/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.57 2011/12/09 16:28:18 nicm Exp $ */
+/* $OpenBSD: cmd.c,v 1.58 2011/12/27 14:07:20 stsp Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 3eea18e490d..1a08e1b442e 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.258 2011/12/24 08:46:48 jmc Exp $
+.\" $OpenBSD: tmux.1,v 1.259 2011/12/27 14:07:20 stsp Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: December 24 2011 $
+.Dd $Mdocdate: December 27 2011 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -1845,6 +1845,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