diff --git a/cmd-list-keys.c b/cmd-list-keys.c index 405c03c7..d8065259 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -35,7 +35,7 @@ "," \ "bind-key #{?key_has_repeat,#{?key_repeat,-r, },} " \ "-T #{p|#{key_table_width}:key_table} " \ - "#{p|#{key_string_width}:key_string} " \ + "#{p|#{key_string_width}:#{q|a:key_string}} " \ "#{key_command}}" static enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmdq_item *); diff --git a/format.c b/format.c index d94c724d..1756c170 100644 --- a/format.c +++ b/format.c @@ -116,6 +116,7 @@ format_job_cmp(struct format_job *fj1, struct format_job *fj2) #define FORMAT_NOT 0x80000 #define FORMAT_NOT_NOT 0x100000 #define FORMAT_REPEAT 0x200000 +#define FORMAT_QUOTE_ARGUMENTS 0x400000 /* Limit on recursion. */ #define FORMAT_LOOP_LIMIT 100 @@ -4182,6 +4183,11 @@ found: found = format_quote_style(saved); free(saved); } + if (modifiers & FORMAT_QUOTE_ARGUMENTS) { + saved = found; + found = args_escape(saved); + free(saved); + } return (found); } @@ -5155,6 +5161,8 @@ format_replace(struct format_expand_state *es, const char *key, size_t keylen, else if (strchr(fm->argv[0], 'e') != NULL || strchr(fm->argv[0], 'h') != NULL) modifiers |= FORMAT_QUOTE_STYLE; + else if (strchr(fm->argv[0], 'a') != NULL) + modifiers |= FORMAT_QUOTE_ARGUMENTS; break; case 'E': modifiers |= FORMAT_EXPAND; diff --git a/tmux.1 b/tmux.1 index 31eda943..a4df059e 100644 --- a/tmux.1 +++ b/tmux.1 @@ -6288,12 +6288,17 @@ of the variable respectively. .Ql q:\& will escape .Xr sh 1 -special characters or with a +special characters; with a .Ql h suffix, escape hash characters (so .Ql # becomes -.Ql ## ) . +.Ql ## ) ; +or with +.Ql a +escape +.Nm +command arguments. .Ql E:\& will expand the format twice, for example .Ql #{E:status\-left}