aboutsummaryrefslogtreecommitdiff
path: root/cmd-respawn-window.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd-respawn-window.c')
-rw-r--r--cmd-respawn-window.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/cmd-respawn-window.c b/cmd-respawn-window.c
index 4c8235e7..30601fe5 100644
--- a/cmd-respawn-window.c
+++ b/cmd-respawn-window.c
@@ -30,31 +30,31 @@ int cmd_respawn_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_respawn_window_entry = {
"respawn-window", "respawnw",
+ "kt:", 0, 1,
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
- CMD_ARG01, "k",
- cmd_target_init,
- cmd_target_parse,
- cmd_respawn_window_exec,
- cmd_target_free,
- cmd_target_print
+ 0,
+ NULL,
+ NULL,
+ cmd_respawn_window_exec
};
int
cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
{
- struct cmd_target_data *data = self->data;
+ struct args *args = self->args;
struct winlink *wl;
struct window *w;
struct window_pane *wp;
struct session *s;
struct environ env;
+ const char *cmd;
char *cause;
- if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
+ if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
return (-1);
w = wl->window;
- if (!cmd_check_flag(data->chflags, 'k')) {
+ if (!args_has(self->args, 'k')) {
TAILQ_FOREACH(wp, &w->panes, entry) {
if (wp->fd == -1)
continue;
@@ -75,8 +75,11 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
window_destroy_panes(w);
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
window_pane_resize(wp, w->sx, w->sy);
- if (window_pane_spawn(
- wp, data->arg, NULL, NULL, &env, s->tio, &cause) != 0) {
+ if (args->argc != 0)
+ cmd = args->argv[0];
+ else
+ cmd = NULL;
+ if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) {
ctx->error(ctx, "respawn window failed: %s", cause);
xfree(cause);
environ_free(&env);