Add option command-prefix which is automatically prepended to any command

(apart from a naked default-shell). The default is "exec ".
This commit is contained in:
Nicholas Marriott
2013-02-22 14:31:38 +00:00
parent 374dae6635
commit 31407b70e0
5 changed files with 55 additions and 17 deletions

View File

@ -58,8 +58,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;
@ -121,9 +121,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);