mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Add -c for respawn-pane and respawn-window, from J Raynor.
This commit is contained in:
		@@ -34,8 +34,9 @@ const struct cmd_entry cmd_respawn_window_entry = {
 | 
			
		||||
	.name = "respawn-window",
 | 
			
		||||
	.alias = "respawnw",
 | 
			
		||||
 | 
			
		||||
	.args = { "kt:", 0, -1 },
 | 
			
		||||
	.usage = "[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
 | 
			
		||||
	.args = { "c:kt:", 0, -1 },
 | 
			
		||||
	.usage = "[-c start-directory] [-k] " CMD_TARGET_WINDOW_USAGE
 | 
			
		||||
	         " [command]",
 | 
			
		||||
 | 
			
		||||
	.target = { 't', CMD_FIND_WINDOW, 0 },
 | 
			
		||||
 | 
			
		||||
@@ -51,9 +52,10 @@ cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
	struct winlink		*wl = item->target.wl;
 | 
			
		||||
	struct window		*w = wl->window;
 | 
			
		||||
	struct window_pane	*wp;
 | 
			
		||||
	struct client           *c = cmd_find_client(item, NULL, 1);
 | 
			
		||||
	struct environ		*env;
 | 
			
		||||
	const char		*path;
 | 
			
		||||
	char		 	*cause;
 | 
			
		||||
	const char		*path = NULL, *cp;
 | 
			
		||||
	char		 	*cause, *cwd = NULL;
 | 
			
		||||
	struct environ_entry	*envent;
 | 
			
		||||
 | 
			
		||||
	if (!args_has(self->args, 'k')) {
 | 
			
		||||
@@ -73,7 +75,6 @@ cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
	TAILQ_INSERT_HEAD(&w->panes, wp, entry);
 | 
			
		||||
	window_pane_resize(wp, w->sx, w->sy);
 | 
			
		||||
 | 
			
		||||
	path = NULL;
 | 
			
		||||
	if (item->client != NULL && item->client->session == NULL)
 | 
			
		||||
		envent = environ_find(item->client->environ, "PATH");
 | 
			
		||||
	else
 | 
			
		||||
@@ -81,16 +82,22 @@ cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
	if (envent != NULL)
 | 
			
		||||
		path = envent->value;
 | 
			
		||||
 | 
			
		||||
	if ((cp = args_get(args, 'c')) != NULL)
 | 
			
		||||
		cwd = format_single(item, cp, c, s, NULL, NULL);
 | 
			
		||||
 | 
			
		||||
	env = environ_for_session(s, 0);
 | 
			
		||||
	if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env,
 | 
			
		||||
	if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, cwd, env,
 | 
			
		||||
	    s->tio, &cause) != 0) {
 | 
			
		||||
		cmdq_error(item, "respawn window failed: %s", cause);
 | 
			
		||||
		free(cause);
 | 
			
		||||
		environ_free(env);
 | 
			
		||||
		free(cwd);
 | 
			
		||||
		server_destroy_pane(wp, 0);
 | 
			
		||||
		return (CMD_RETURN_ERROR);
 | 
			
		||||
	}
 | 
			
		||||
	environ_free(env);
 | 
			
		||||
	free(cwd);
 | 
			
		||||
 | 
			
		||||
	layout_init(w, wp);
 | 
			
		||||
	window_pane_reset_mode(wp);
 | 
			
		||||
	screen_reinit(&wp->base);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user