From e006b06ea0c3dfa1cf5fb872055f78f9895b6d4f Mon Sep 17 00:00:00 2001 From: Thomas Preston Date: Sat, 9 May 2020 13:38:02 +0100 Subject: [PATCH] swapper: Make quotes optional in key-value regex The regular expression describing the tmux user options expects to find quotes around the value. However, in at least tmux 3.0a the `show-options -g` command doesn't display quotes around the values, which means the regex fails. For example, the current regex will fail to find these user options: $ tmux -V tmux 3.0a $ tmux show -g | grep -E "@thumbs" @thumbs-bg-color default @thumbs-fg-color green @thumbs-hint-bg-color default @thumbs-hint-fg-color blue @thumbs-select-bg-color default @thumbs-select-fg-color green Make the quotes optional so that these options are picked up. Fixes #33 --- src/swapper.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/swapper.rs b/src/swapper.rs index b6b4f3a..f5994fa 100644 --- a/src/swapper.rs +++ b/src/swapper.rs @@ -127,7 +127,7 @@ impl<'a> Swapper<'a> { let options = self.executor.execute(params); let lines: Vec<&str> = options.split('\n').collect(); - let pattern = Regex::new(r#"@thumbs-([\w\-0-9]+) "(.*)""#).unwrap(); + let pattern = Regex::new(r#"@thumbs-([\w\-0-9]+) "?(\w+)"?"#).unwrap(); let args = lines .iter()