diff --git a/cmd-display-message.c b/cmd-display-message.c index 0e294ef50..4c29248a1 100644 --- a/cmd-display-message.c +++ b/cmd-display-message.c @@ -115,11 +115,15 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item) /* * -c is intended to be the client where the message should be - * displayed if -p is not given. But it makes sense to use it for the - * formats too, assuming it matches the session. If it doesn't, use the - * best client for the session. + * displayed if -p is not given, but it makes sense to use it for the + * client formats too. If it was given explicitly, use it even when it + * is not in the target session, since the formats should describe the + * client which was asked for; the session, window and pane formats + * still come from the target. Otherwise it is just the current client, + * so only use it if it matches the session and fall back to the best + * client for the session if not. */ - if (tc != NULL && tc->session == s) + if (tc != NULL && (args_has(args, 'c') || tc->session == s)) c = tc; else if (s != NULL) c = cmd_find_best_client(s); diff --git a/tmux.1 b/tmux.1 index 56790f9f0..3a1bae73f 100644 --- a/tmux.1 +++ b/tmux.1 @@ -8328,11 +8328,17 @@ Otherwise, the format of .Ar message is described in the .Sx FORMATS -section; information is taken from +section; session, window and pane information is taken from .Ar target\-pane if .Fl t is given, otherwise the active pane. +If +.Fl c +is given, the +.Ql #{client_*} +variables are taken from +.Ar target\-client . .Pp If .Fl j