diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c
index 8f7250e8..81e1f7f9 100644
--- a/cmd-capture-pane.c
+++ b/cmd-capture-pane.c
@@ -39,8 +39,8 @@ const struct cmd_entry cmd_capture_pane_entry = {
 	.name = "capture-pane",
 	.alias = "capturep",
 
-	.args = { "ab:CeE:JNpPqS:Tt:", 0, 0, NULL },
-	.usage = "[-aCeJNpPqT] " CMD_BUFFER_USAGE " [-E end-line] "
+	.args = { "ab:CeE:JMNpPqS:Tt:", 0, 0, NULL },
+	.usage = "[-aCeJMNpPqT] " CMD_BUFFER_USAGE " [-E end-line] "
 		 "[-S start-line] " CMD_TARGET_PANE_USAGE,
 
 	.target = { 't', CMD_FIND_PANE, 0 },
@@ -107,14 +107,16 @@ static char *
 cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
     struct window_pane *wp, size_t *len)
 {
-	struct grid		*gd;
-	const struct grid_line	*gl;
-	struct grid_cell	*gc = NULL;
-	int			 n, join_lines, flags = 0;
-	u_int			 i, sx, top, bottom, tmp;
-	char			*cause, *buf, *line;
-	const char		*Sflag, *Eflag;
-	size_t			 linelen;
+	struct grid			*gd;
+	const struct grid_line		*gl;
+	struct screen			*s;
+	struct grid_cell		*gc = NULL;
+	struct window_mode_entry	*wme;
+	int				 n, join_lines, flags = 0;
+	u_int				 i, sx, top, bottom, tmp;
+	char				*cause, *buf, *line;
+	const char			*Sflag, *Eflag;
+	size_t				 linelen;
 
 	sx = screen_size_x(&wp->base);
 	if (args_has(args, 'a')) {
@@ -126,8 +128,20 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
 			}
 			return (xstrdup(""));
 		}
-	} else
+		s = &wp->base;
+	} else if (args_has(args, 'M')) {
+		wme = TAILQ_FIRST(&wp->modes);
+		if (wme != NULL && wme->mode->get_screen != NULL) {
+			s = wme->mode->get_screen (wme);
+			gd = s->grid;
+		} else {
+			s = &wp->base;
+			gd = wp->base.grid;
+		}
+	} else {
+		s = &wp->base;
 		gd = wp->base.grid;
+	}
 
 	Sflag = args_get(args, 'S');
 	if (Sflag != NULL && strcmp(Sflag, "-") == 0)
@@ -181,7 +195,7 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
 
 	buf = NULL;
 	for (i = top; i <= bottom; i++) {
-		line = grid_string_cells(gd, 0, i, sx, &gc, flags, wp->screen);
+		line = grid_string_cells(gd, 0, i, sx, &gc, flags, s);
 		linelen = strlen(line);
 
 		buf = cmd_capture_pane_append(buf, len, line, linelen);
diff --git a/tmux.1 b/tmux.1
index ed6e7a53..5c979758 100644
--- a/tmux.1
+++ b/tmux.1
@@ -2554,7 +2554,7 @@ but a different format may be specified with
 .Fl F .
 .Tg capturep
 .It Xo Ic capture-pane
-.Op Fl aAepPqCJN
+.Op Fl aepPqCJMN
 .Op Fl b Ar buffer-name
 .Op Fl E Ar end-line
 .Op Fl S Ar start-line
@@ -2573,6 +2573,9 @@ is given, the alternate screen is used, and the history is not accessible.
 If no alternate screen exists, an error will be returned unless
 .Fl q
 is given.
+Similarly, if the pane is in a mode,
+.Fl M
+uses the screen for the mode.
 If
 .Fl e
 is given, the output includes escape sequences for text and background
diff --git a/tmux.h b/tmux.h
index 065bb042..cd93097e 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1059,6 +1059,7 @@ struct window_mode {
 			     struct mouse_event *);
 	void		 (*formats)(struct window_mode_entry *,
 			     struct format_tree *);
+	struct screen	*(*get_screen)(struct window_mode_entry *);
 };
 
 /* Active window mode. */
diff --git a/window-copy.c b/window-copy.c
index 1cda6d39..7dcc8432 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -40,6 +40,7 @@ static void	window_copy_free(struct window_mode_entry *);
 static void	window_copy_resize(struct window_mode_entry *, u_int, u_int);
 static void	window_copy_formats(struct window_mode_entry *,
 		    struct format_tree *);
+static struct screen *window_copy_get_screen(struct window_mode_entry *);
 static void	window_copy_scroll1(struct window_mode_entry *,
 		    struct window_pane *wp, int, u_int, int);
 static void	window_copy_pageup1(struct window_mode_entry *, int);
@@ -160,6 +161,7 @@ const struct window_mode window_copy_mode = {
 	.key_table = window_copy_key_table,
 	.command = window_copy_command,
 	.formats = window_copy_formats,
+	.get_screen = window_copy_get_screen
 };
 
 const struct window_mode window_view_mode = {
@@ -171,6 +173,7 @@ const struct window_mode window_view_mode = {
 	.key_table = window_copy_key_table,
 	.command = window_copy_command,
 	.formats = window_copy_formats,
+	.get_screen = window_copy_get_screen
 };
 
 enum {
@@ -972,6 +975,14 @@ window_copy_formats(struct window_mode_entry *wme, struct format_tree *ft)
 	    window_copy_cursor_hyperlink_cb);
 }
 
+static struct screen *
+window_copy_get_screen(struct window_mode_entry *wme)
+{
+	struct window_copy_mode_data	*data = wme->data;
+
+	return (data->backing);
+}
+
 static void
 window_copy_size_changed(struct window_mode_entry *wme)
 {