From 9f39652d87e649ca7456df9e5b67899a3181792e Mon Sep 17 00:00:00 2001
From: nicm <nicm>
Date: Mon, 23 Apr 2018 13:43:08 +0000
Subject: [PATCH 1/4] Remove unnecessary brackets.

---
 cmd-display-message.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/cmd-display-message.c b/cmd-display-message.c
index 59f25543..5856e2d8 100644
--- a/cmd-display-message.c
+++ b/cmd-display-message.c
@@ -89,10 +89,8 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
 	msg = format_expand_time(ft, template, time(NULL));
 	if (args_has(self->args, 'p'))
 		cmdq_print(item, "%s", msg);
-	else {
-		if (c != NULL)
-			status_message_set(c, "%s", msg);
-	}
+	else if (c != NULL)
+		status_message_set(c, "%s", msg);
 	free(msg);
 
 	format_free(ft);

From 4bf6f2706ee9cb0310cfc4756a50c11072795734 Mon Sep 17 00:00:00 2001
From: nicm <nicm>
Date: Mon, 23 Apr 2018 13:46:34 +0000
Subject: [PATCH 2/4] Check whether cursor is at start or end when copying
 rectangular selections, from tb@.

---
 window-copy.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/window-copy.c b/window-copy.c
index 6eb3d435..09025497 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1548,7 +1548,7 @@ window_copy_get_selection(struct window_pane *wp, size_t *len)
 	char				*buf;
 	size_t				 off;
 	u_int				 i, xx, yy, sx, sy, ex, ey, ey_last;
-	u_int				 firstsx, lastex, restex, restsx;
+	u_int				 firstsx, lastex, restex, restsx, selx;
 	int				 keys;
 
 	if (!s->sel.flag && s->sel.lineflag == LINE_SEL_NONE)
@@ -1599,7 +1599,11 @@ window_copy_get_selection(struct window_pane *wp, size_t *len)
 		 * Need to ignore the column with the cursor in it, which for
 		 * rectangular copy means knowing which side the cursor is on.
 		 */
-		if (data->selx < data->cx) {
+		if (data->cursordrag == CURSORDRAG_ENDSEL)
+			selx = data->selx;
+		else
+			selx = data->endselx;
+		if (selx < data->cx) {
 			/* Selection start is on the left. */
 			if (keys == MODEKEY_EMACS) {
 				lastex = data->cx;
@@ -1609,12 +1613,12 @@ window_copy_get_selection(struct window_pane *wp, size_t *len)
 				lastex = data->cx + 1;
 				restex = data->cx + 1;
 			}
-			firstsx = data->selx;
-			restsx = data->selx;
+			firstsx = selx;
+			restsx = selx;
 		} else {
 			/* Cursor is on the left. */
-			lastex = data->selx + 1;
-			restex = data->selx + 1;
+			lastex = selx + 1;
+			restex = selx + 1;
 			firstsx = data->cx;
 			restsx = data->cx;
 		}

From 068d1b97b225f2914e6e7c14b20ae2b77e016a28 Mon Sep 17 00:00:00 2001
From: nicm <nicm>
Date: Mon, 23 Apr 2018 13:51:21 +0000
Subject: [PATCH 3/4] #aabbcc will use RGB if supported so don't say it is
 closest match.

---
 tmux.1 | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tmux.1 b/tmux.1
index 5a6103a1..2d8edff9 100644
--- a/tmux.1
+++ b/tmux.1
@@ -2751,8 +2751,7 @@ to
 from the 256-colour set,
 .Ic default ,
 or a hexadecimal RGB string such as
-.Ql #ffffff ,
-which chooses the closest match from the default 256-colour set.
+.Ql #ffffff .
 .Pp
 The attributes is either
 .Ic none

From d9d2f84a4b143d4f45dc11ed31573f667868e5eb Mon Sep 17 00:00:00 2001
From: nicm <nicm>
Date: Mon, 23 Apr 2018 14:03:06 +0000
Subject: [PATCH 4/4] Add KRB5CCNAME to update-environment.

---
 options-table.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/options-table.c b/options-table.c
index 20ac5d6f..03ee530f 100644
--- a/options-table.c
+++ b/options-table.c
@@ -514,8 +514,8 @@ const struct options_table_entry options_table[] = {
 	{ .name = "update-environment",
 	  .type = OPTIONS_TABLE_ARRAY,
 	  .scope = OPTIONS_TABLE_SESSION,
-	  .default_str = "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID "
-			 "SSH_CONNECTION WINDOWID XAUTHORITY"
+	  .default_str = "DISPLAY KRB5CCNAME SSH_ASKPASS SSH_AUTH_SOCK "
+	  		 "SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"
 	},
 
 	{ .name = "visual-activity",