diff --git a/src/main.rs b/src/main.rs index 91c200f..6972eb7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,6 +61,10 @@ fn app_args<'a> () -> clap::ArgMatches<'a> { .long("position") .default_value("left") .short("p")) + .arg(Arg::with_name("tmux_pane") + .help("Get this tmux pane as reference pane") + .long("tmux-pane") + .takes_value(true)) .arg(Arg::with_name("command") .help("Pick command") .long("command") @@ -87,8 +91,13 @@ fn main() { let command = args.value_of("command").unwrap(); let upcase_command = args.value_of("upcase_command").unwrap(); + let tmux_subcommand = if let Some(pane) = args.value_of("tmux_pane") { + format!(" -t {}", pane) + } else { + "".to_string() + }; - let execution = exec_command(format!("tmux capture-pane -e -J -p")); + let execution = exec_command(format!("tmux capture-pane -e -J -p{}", tmux_subcommand)); let output = String::from_utf8_lossy(&execution.stdout); let lines = output.split("\n").collect::>(); @@ -110,6 +119,11 @@ fn main() { viewbox.present() }; + if let Some(pane) = args.value_of("tmux_pane") { + exec_command(format!("tmux swap-pane -t {}", pane)); + }; + + if let Some((text, paste)) = selected { exec_command(str::replace(command, "{}", text.as_str())); diff --git a/tmux-thumbs.sh b/tmux-thumbs.sh index 913dea7..2159aa2 100755 --- a/tmux-thumbs.sh +++ b/tmux-thumbs.sh @@ -1,3 +1,10 @@ #!/usr/bin/env bash -/home/ubuntu/dev/tmux-thumbs/target/release/tmux-thumbs -a qwerty -r -u +CURRENT_PANE_ID=$(tmux list-panes -F "#{pane_id}:#{?pane_active,active,nope}" | grep active | cut -d: -f1) +COMMAND="/home/ubuntu/dev/tmux-thumbs/target/debug/tmux-thumbs -a qwerty -r -u --tmux-pane ${CURRENT_PANE_ID}" + +tmux new-window -d -n "[thumbs]" ${COMMAND} + +NEW_PANE_ID=$(tmux list-panes -a | grep 0:3.1 | grep -o '%[0-9]\+') + +tmux swap-pane -t ${NEW_PANE_ID}