diff --git a/copyrat.tmux b/copyrat.tmux index c3ee0bd..3097848 100755 --- a/copyrat.tmux +++ b/copyrat.tmux @@ -91,6 +91,8 @@ setup_pattern_binding "D" "--pattern-name docker" setup_pattern_binding "c" "--pattern-name hexcolor" # prefix + t + U searches for UUIDs setup_pattern_binding "U" "--pattern-name uuid" +# prefix + t + v searches for version numbers +setup_pattern_binding "v" "--pattern-name version" # prefix + t + d searches for any string of 4+ digits setup_pattern_binding "d" "--pattern-name digits" # prefix + t + m searches for hex numbers: 0xbedead diff --git a/src/output_destination.rs b/src/output_destination.rs index e6fdbe9..4bbd858 100644 --- a/src/output_destination.rs +++ b/src/output_destination.rs @@ -23,7 +23,7 @@ impl OutputDestination { impl fmt::Display for OutputDestination { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Tmux => write!(f, "tmux"), + Self::Tmux => write!(f, "tmux buffer"), Self::Clipboard => write!(f, "clipboard"), } } diff --git a/src/regexes.rs b/src/regexes.rs index 4c0fd4d..aa90139 100644 --- a/src/regexes.rs +++ b/src/regexes.rs @@ -7,7 +7,7 @@ pub const EXCLUDE_PATTERNS: [(&str, &str); 1] = /// /// The email address was obtained at https://www.regular-expressions.info/email.html. /// Others were obtained from Ferran Basora. -pub const PATTERNS: [(&str, &str); 15] = [ +pub const PATTERNS: [(&str, &str); 16] = [ ("markdown-url", r"\[[^]]*\]\(([^)]+)\)"), ( "url", @@ -23,6 +23,10 @@ pub const PATTERNS: [(&str, &str); 15] = [ "uuid", r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", ), + ( + "version", + r"(v?\d{1,4}\.\d{1,4}(\.\d{1,4})?(-(alpha|beta|rc)(\.\d)?)?)[^.0-9s]", + ), ("ipfs", r"Qm[0-9a-zA-Z]{44}"), ("sha", r"[0-9a-f]{7,40}"), ("ipv4", r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"), diff --git a/src/tmux_copyrat.rs b/src/tmux_copyrat.rs index 3b05e08..fb9e908 100644 --- a/src/tmux_copyrat.rs +++ b/src/tmux_copyrat.rs @@ -33,8 +33,8 @@ struct BridgeOpt { /// Name of the copy-to-clipboard executable. /// - /// If the output destination is set to keyboard, copyrat will pipe the - /// selected text to this executable. + /// If during execution, the output destination is set to be clipboard, + /// then copyrat will pipe the selected text to this executable. #[clap(long, default_value = "pbcopy")] clipboard_exe: String, @@ -94,8 +94,8 @@ fn main() -> Result<(), error::ParseError> { tmux::swap_pane_with(&temp_pane_spec)?; - // Finally copy selection to a tmux buffer, and paste it to the active - // buffer if it was uppercased. + // Finally copy selection to the output destination (tmux buffer or + // clipboard), and paste it to the active buffer if it was uppercased. match selection { None => return Ok(()), @@ -105,25 +105,14 @@ fn main() -> Result<(), error::ParseError> { output_destination, }) => { if uppercased { - // let args = vec!["send-keys", "-t", active_pane.id.as_str(), &text]; - // process::execute("tmux", &args)?; duct::cmd!("tmux", "send-keys", "-t", active_pane.id.as_str(), &text).run()?; } match output_destination { OutputDestination::Tmux => { - // let args = vec!["set-buffer", &text]; - // process::execute("tmux", &args)?; duct::cmd!("tmux", "set-buffer", &text).run()?; - - // if uppercased { - // let args = vec!["paste-buffer", "-t", active_pane.id.as_str()]; - // process::execute("tmux", &args)?; - // } } OutputDestination::Clipboard => { - // let args = [("echo", vec![&text[..]]), ("pbcopy", vec![])]; - // process::execute_piped(&args[..])?; duct::cmd!("echo", "-n", &text) .pipe(duct::cmd!(opt.clipboard_exe)) .read()?;