diff --git i/cmd-if-shell.c w/cmd-if-shell.c
index dddd5d4..3471cb1 100644
--- i/cmd-if-shell.c
+++ w/cmd-if-shell.c
@@ -64,7 +64,8 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
 	struct window_pane		*wp = NULL;
 	struct format_tree		*ft;
 
-	if (args_has(args, 't'))
+	if (args_has(args, 't') ||
+	    cmd_current_session(cmdq, 0) != NULL)
 		wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp);
 
 	ft = format_create();
diff --git i/cmd-run-shell.c w/cmd-run-shell.c
index 4df21ff..71b5047 100644
--- i/cmd-run-shell.c
+++ w/cmd-run-shell.c
@@ -82,7 +82,8 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq)
 	struct window_pane		*wp = NULL;
 	struct format_tree		*ft;
 
-	if (args_has(args, 't'))
+	if (args_has(args, 't') ||
+	    cmd_current_session(cmdq, 0) != NULL)
 		wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp);
 
 	ft = format_create();
