Ok here is the updated patch
---
cmd-if-shell.c | 20 ++++++++++++++++++--
cmd-run-shell.c | 18 ++++++++++++++----
tmux.1 | 10 ++++++++--
3 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/cmd-if-shell.c b/cmd-if-shell.c
index 6f0b151..011974f 100644
--- a/cmd-if-shell.c
+++ b/cmd-if-shell.c
@@ -55,7 +55,21 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct args *args = self->args;
struct cmd_if_shell_data *cdata;
- const char *shellcmd = args->argv[0];
+ const char *shellcmd;
+ struct session *s;
+ struct winlink *wl;
+ struct window_pane *wp;
+ struct format_tree *ft;
+
+ wl = cmd_find_pane(ctx, NULL, &s, &wp);
+ if (wl == NULL)
+ return (CMD_RETURN_ERROR);
+
+ ft = format_create();
+ format_session(ft, s);
+ format_winlink(ft, s, wl);
+ format_window_pane(ft, wp);
+ shellcmd = format_expand(ft, args->argv[0]);
cdata = xmalloc(sizeof *cdata);
cdata->cmd_if = xstrdup(args->argv[1]);
@@ -68,7 +82,9 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
cmd_ref_ctx(ctx);
job_run(shellcmd, cmd_if_shell_callback, cmd_if_shell_free, cdata);
-
+ format_free(ft);
+ free(shellcmd);
+
return (CMD_RETURN_YIELD); /* don't let client exit */
}
diff --git a/cmd-run-shell.c b/cmd-run-shell.c
index 9b4c006..69423e5 100644
--- a/cmd-run-shell.c
+++ b/cmd-run-shell.c
@@ -75,20 +75,30 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct args *args = self->args;
struct cmd_run_shell_data *cdata;
- const char *shellcmd = args->argv[0];
+ const char *shellcmd;
+ struct session *s;
+ struct winlink *wl;
struct window_pane *wp;
+ struct format_tree *ft;
- if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
+ wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp);
+ if (wl == NULL)
return (CMD_RETURN_ERROR);
+ ft = format_create();
+ format_session(ft, s);
+ format_winlink(ft, s, wl);
+ format_window_pane(ft, wp);
+ shellcmd = format_expand(ft, args->argv[0]);
+
cdata = xmalloc(sizeof *cdata);
- cdata->cmd = xstrdup(args->argv[0]);
+ cdata->cmd = shellcmd;
cdata->wp_id = wp->id;
-
cdata->ctx = ctx;
cmd_ref_ctx(ctx);
job_run(shellcmd, cmd_run_shell_callback, cmd_run_shell_free, cdata);
+ format_free(ft);
return (CMD_RETURN_YIELD); /* don't let client exit */
}
diff --git a/tmux.1 b/tmux.1
index 882a71f..d01a150 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3476,7 +3476,10 @@ if
.Ar shell-command
returns success or the second
.Ar command
-otherwise.
+otherwise. Before being executed, shell-command is expanded using the rules
+specified in the
+.Sx FORMATS
+section.
.It Ic lock-server
.D1 (alias: Ic lock )
Lock each client individually by running the command specified by the
@@ -3489,7 +3492,10 @@ option.
.D1 (alias: Ic run )
Execute
.Ar shell-command
-in the background without creating a window.
+in the background without creating a window. Before being executed,
+shell-command is expanded using the rules specified in the
+.Sx FORMATS
+section.
After it finishes, any output to stdout is displayed in copy mode (in the pane
specified by
.Fl t
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users