diff options
author | nicm <nicm> | 2015-04-24 22:19:36 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-04-24 22:19:36 +0000 |
commit | 583b4ab72b7bf66fda8ab63a08fe435483de5e5a (patch) | |
tree | 7620822095c73c5d78942cdfa7005d6a6f50019d /cmd-run-shell.c | |
parent | 5a2d0533a84a13613fb356b66ed8ada2a65f6edf (diff) |
Set working directory for run-shell and if-shell.
Diffstat (limited to 'cmd-run-shell.c')
-rw-r--r-- | cmd-run-shell.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/cmd-run-shell.c b/cmd-run-shell.c index 5d6d178b..134cbeba 100644 --- a/cmd-run-shell.c +++ b/cmd-run-shell.c @@ -80,16 +80,24 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq) struct winlink *wl = NULL; struct window_pane *wp = NULL; struct format_tree *ft; + int cwd; - if (args_has(args, 't')) + if (args_has(args, 't')) { wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp); - else { + cwd = wp->cwd; + } else { c = cmd_find_client(cmdq, NULL, 1); if (c != NULL && c->session != NULL) { s = c->session; wl = s->curw; wp = wl->window->active; } + if (cmdq->client != NULL && cmdq->client->session == NULL) + cwd = cmdq->client->cwd; + else if (s != NULL) + cwd = s->cwd; + else + cwd = -1; } ft = format_create(); @@ -105,7 +113,8 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq) cdata->cmdq = cmdq; cmdq->references++; - job_run(shellcmd, s, cmd_run_shell_callback, cmd_run_shell_free, cdata); + job_run(shellcmd, s, cwd, cmd_run_shell_callback, cmd_run_shell_free, + cdata); if (cdata->bflag) return (CMD_RETURN_NORMAL); |