summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.bin/tmux/cmd-split-window.c19
-rw-r--r--usr.bin/tmux/names.c26
-rw-r--r--usr.bin/tmux/options-table.c8
-rw-r--r--usr.bin/tmux/tmux.19
-rw-r--r--usr.bin/tmux/window.c20
5 files changed, 60 insertions, 22 deletions
diff --git a/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c
index ef9b37b63ee..b492e30767f 100644
--- a/usr.bin/tmux/cmd-split-window.c
+++ b/usr.bin/tmux/cmd-split-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-split-window.c,v 1.37 2012/12/09 23:17:35 nicm Exp $ */
+/* $OpenBSD: cmd-split-window.c,v 1.38 2013/03/24 09:21:27 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -59,8 +59,8 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
struct window *w;
struct window_pane *wp, *new_wp = NULL;
struct environ env;
- const char *cmd, *cwd, *shell;
- char *cause, *new_cause;
+ const char *cmd, *cwd, *shell, *prefix;
+ char *cause, *new_cause, *cmd1;
u_int hlimit;
int size, percentage;
enum layout_type type;
@@ -122,9 +122,18 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
goto error;
}
new_wp = window_add_pane(w, hlimit);
- if (window_pane_spawn(
- new_wp, cmd, shell, cwd, &env, s->tio, &cause) != 0)
+
+ if (*cmd != '\0') {
+ prefix = options_get_string(&w->options, "command-prefix");
+ xasprintf(&cmd1, "%s%s", prefix, cmd);
+ } else
+ cmd1 = xstrdup("");
+ if (window_pane_spawn(new_wp, cmd1, shell, cwd, &env, s->tio,
+ &cause) != 0) {
+ free(cmd1);
goto error;
+ }
+ free(cmd1);
layout_assign_pane(lc, new_wp);
server_redraw_window(w);
diff --git a/usr.bin/tmux/names.c b/usr.bin/tmux/names.c
index 4e11d6bf21e..53df39cb4d9 100644
--- a/usr.bin/tmux/names.c
+++ b/usr.bin/tmux/names.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: names.c,v 1.19 2013/03/22 10:31:22 nicm Exp $ */
+/* $OpenBSD: names.c,v 1.20 2013/03/24 09:21:27 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -26,8 +26,8 @@
#include "tmux.h"
-void window_name_callback(unused int, unused short, void *);
-char *parse_window_name(const char *);
+void window_name_callback(int, short, void *);
+char *parse_window_name(struct window *, const char *);
void
queue_window_name(struct window *w)
@@ -73,9 +73,9 @@ window_name_callback(unused int fd, unused short events, void *data)
*/
if (w->active->cmd != NULL && *w->active->cmd == '\0' &&
name != NULL && name[0] == '-' && name[1] != '\0')
- wname = parse_window_name(name + 1);
+ wname = parse_window_name(w, name + 1);
else
- wname = parse_window_name(name);
+ wname = parse_window_name(w, name);
free(name);
}
@@ -98,18 +98,22 @@ default_window_name(struct window *w)
if (w->active->screen != &w->active->base)
return (xstrdup("[tmux]"));
if (w->active->cmd != NULL && *w->active->cmd != '\0')
- return (parse_window_name(w->active->cmd));
- return (parse_window_name(w->active->shell));
+ return (parse_window_name(w, w->active->cmd));
+ return (parse_window_name(w, w->active->shell));
}
char *
-parse_window_name(const char *in)
+parse_window_name(struct window *w, const char *in)
{
- char *copy, *name, *ptr;
+ char *copy, *name, *ptr, *prefix;
+ size_t prefixlen;
+
+ prefix = options_get_string(&w->options, "command-prefix");
+ prefixlen = strlen(prefix);
name = copy = xstrdup(in);
- if (strncmp(name, "exec ", (sizeof "exec ") - 1) == 0)
- name = name + (sizeof "exec ") - 1;
+ if (strncmp(name, prefix, prefixlen) == 0)
+ name = name + prefixlen;
while (*name == ' ')
name++;
diff --git a/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c
index ae7efd7f5a3..831b0d01ada 100644
--- a/usr.bin/tmux/options-table.c
+++ b/usr.bin/tmux/options-table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options-table.c,v 1.33 2013/03/21 16:15:52 nicm Exp $ */
+/* $OpenBSD: options-table.c,v 1.34 2013/03/24 09:21:27 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -477,7 +477,6 @@ const struct options_table_entry window_options_table[] = {
.default_num = 1
},
-
{ .name = "c0-change-trigger",
.type = OPTIONS_TABLE_NUMBER,
.default_num = 250,
@@ -503,6 +502,11 @@ const struct options_table_entry window_options_table[] = {
.default_num = 1
},
+ { .name = "command-prefix",
+ .type = OPTIONS_TABLE_STRING,
+ .default_str = "exec "
+ },
+
{ .name = "force-height",
.type = OPTIONS_TABLE_NUMBER,
.minimum = 0,
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index d3575093990..8b1545ae39d 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.331 2013/03/24 09:19:51 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.332 2013/03/24 09:21:27 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -2704,6 +2704,13 @@ Set clock colour.
.Xc
Set clock hour format.
.Pp
+.It Ic command-prefix Ar string
+String prefixed to commands (apart from a plain shell as set by the
+.Ic default-shell
+option).
+The default is
+.Ql "exec\ " .
+.Pp
.It Ic force-height Ar height
.It Ic force-width Ar width
Prevent
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 6d75fa0b7cf..8d219ce9cc3 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.90 2013/03/22 10:31:22 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.91 2013/03/24 09:21:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -310,24 +310,36 @@ window_create1(u_int sx, u_int sy)
struct window *
window_create(const char *name, const char *cmd, const char *shell,
const char *cwd, struct environ *env, struct termios *tio,
- u_int sx, u_int sy, u_int hlimit,char **cause)
+ u_int sx, u_int sy, u_int hlimit, char **cause)
{
struct window *w;
struct window_pane *wp;
+ const char *prefix;
+ char *cmd1;
w = window_create1(sx, sy);
wp = window_add_pane(w, hlimit);
layout_init(w);
- if (window_pane_spawn(wp, cmd, shell, cwd, env, tio, cause) != 0) {
+
+ if (*cmd != '\0') {
+ prefix = options_get_string(&w->options, "command-prefix");
+ xasprintf(&cmd1, "%s%s", prefix, cmd);
+ } else
+ cmd1 = xstrdup("");
+ if (window_pane_spawn(wp, cmd1, shell, cwd, env, tio, cause) != 0) {
window_destroy(w);
+ free(cmd1);
return (NULL);
}
+ free(cmd1);
+
w->active = TAILQ_FIRST(&w->panes);
if (name != NULL) {
w->name = xstrdup(name);
options_set_number(&w->options, "automatic-rename", 0);
} else
w->name = default_window_name(w);
+
return (w);
}
@@ -704,6 +716,8 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
wp->cwd = xstrdup(cwd);
}
+ log_debug("spawn: %s -- %s", wp->shell, wp->cmd);
+
memset(&ws, 0, sizeof ws);
ws.ws_col = screen_size_x(&wp->base);
ws.ws_row = screen_size_y(&wp->base);