mirror of
https://github.com/FliegendeWurst/tmux-thumbs.git
synced 2024-11-09 16:00:35 +00:00
Pane swaping working
This commit is contained in:
parent
cabbac442a
commit
cd348adc18
16
src/main.rs
16
src/main.rs
@ -61,6 +61,10 @@ fn app_args<'a> () -> clap::ArgMatches<'a> {
|
|||||||
.long("position")
|
.long("position")
|
||||||
.default_value("left")
|
.default_value("left")
|
||||||
.short("p"))
|
.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")
|
.arg(Arg::with_name("command")
|
||||||
.help("Pick command")
|
.help("Pick command")
|
||||||
.long("command")
|
.long("command")
|
||||||
@ -87,8 +91,13 @@ fn main() {
|
|||||||
|
|
||||||
let command = args.value_of("command").unwrap();
|
let command = args.value_of("command").unwrap();
|
||||||
let upcase_command = args.value_of("upcase_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 output = String::from_utf8_lossy(&execution.stdout);
|
||||||
let lines = output.split("\n").collect::<Vec<&str>>();
|
let lines = output.split("\n").collect::<Vec<&str>>();
|
||||||
|
|
||||||
@ -110,6 +119,11 @@ fn main() {
|
|||||||
viewbox.present()
|
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 {
|
if let Some((text, paste)) = selected {
|
||||||
exec_command(str::replace(command, "{}", text.as_str()));
|
exec_command(str::replace(command, "{}", text.as_str()));
|
||||||
|
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/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}
|
||||||
|
Loading…
Reference in New Issue
Block a user