From 02ef06f34e702cb6c728d102ccca7817bc189392 Mon Sep 17 00:00:00 2001 From: "Daniel M. Capella" Date: Tue, 4 Aug 2020 18:30:54 -0400 Subject: [PATCH] Global install --- src/swapper.rs | 10 +--------- tmux-thumbs.sh | 6 ++---- tmux-thumbs.tmux | 10 +--------- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/swapper.rs b/src/swapper.rs index cce19e0..e2fc3d8 100644 --- a/src/swapper.rs +++ b/src/swapper.rs @@ -57,7 +57,6 @@ fn dbg(msg: &str) { pub struct Swapper<'a> { executor: Box<&'a mut dyn Executor>, - dir: String, command: String, upcase_command: String, multi_command: String, @@ -74,7 +73,6 @@ pub struct Swapper<'a> { impl<'a> Swapper<'a> { fn new( executor: Box<&'a mut dyn Executor>, - dir: String, command: String, upcase_command: String, multi_command: String, @@ -87,7 +85,6 @@ impl<'a> Swapper<'a> { Swapper { executor, - dir, command, upcase_command, multi_command, @@ -213,11 +210,10 @@ impl<'a> Swapper<'a> { }; let pane_command = format!( - "tmux capture-pane -t {active_pane_id} -p{scroll_params} | tail -n {height} | {dir}/target/release/thumbs -f '%U:%H' -t {tmp} {args}; tmux swap-pane -t {active_pane_id}; {zoom_command} tmux wait-for -S {signal}", + "tmux capture-pane -t {active_pane_id} -p{scroll_params} | tail -n {height} | thumbs -f '%U:%H' -t {tmp} {args}; tmux swap-pane -t {active_pane_id}; {zoom_command} tmux wait-for -S {signal}", active_pane_id = active_pane_id, scroll_params = scroll_params, height = self.active_pane_height.unwrap_or(i32::MAX), - dir = self.dir, tmp = TMP_FILE, args = args.join(" "), zoom_command = zoom_command, @@ -447,7 +443,6 @@ mod tests { "".to_string(), "".to_string(), "".to_string(), - "".to_string(), false, ); @@ -470,7 +465,6 @@ mod tests { "".to_string(), "".to_string(), "".to_string(), - "".to_string(), false, ); @@ -493,7 +487,6 @@ mod tests { let multi_command = "open \"{}\"".to_string(); let mut swapper = Swapper::new( Box::new(&mut executor), - "".to_string(), user_command, upcase_command, multi_command, @@ -578,7 +571,6 @@ fn main() -> std::io::Result<()> { let mut executor = RealShell::new(); let mut swapper = Swapper::new( Box::new(&mut executor), - dir.to_string(), command.to_string(), upcase_command.to_string(), multi_command.to_string(), diff --git a/tmux-thumbs.sh b/tmux-thumbs.sh index 92d5625..f1e0a26 100755 --- a/tmux-thumbs.sh +++ b/tmux-thumbs.sh @@ -1,8 +1,6 @@ #!/usr/bin/env bash set -Eeu -o pipefail -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - function get-opt-value() { tmux show -vg "@thumbs-${1}" 2> /dev/null } @@ -21,7 +19,7 @@ function get-opt-arg() { fi } -PARAMS=(--dir "${CURRENT_DIR}") +PARAMS=(--dir /usr/share/thumbs) function add-param() { local type opt arg @@ -35,4 +33,4 @@ add-param command string add-param upcase-command string add-param osc52 boolean -"${CURRENT_DIR}/target/release/tmux-thumbs" "${PARAMS[@]}" || true +tmux-thumbs "${PARAMS[@]}" || true diff --git a/tmux-thumbs.tmux b/tmux-thumbs.tmux index 4fc9355..dc03d1d 100755 --- a/tmux-thumbs.tmux +++ b/tmux-thumbs.tmux @@ -1,16 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - DEFAULT_THUMBS_KEY=space THUMBS_KEY="$(tmux show-option -gqv @thumbs-key)" THUMBS_KEY=${THUMBS_KEY:-$DEFAULT_THUMBS_KEY} -tmux bind-key "${THUMBS_KEY}" run-shell -b "${CURRENT_DIR}/tmux-thumbs.sh" - -BINARY="${CURRENT_DIR}/target/release/thumbs" - -if [ ! -f "$BINARY" ]; then - tmux split-window "cd ${CURRENT_DIR} && cargo build --release --target-dir=target && echo 'Press any key to continue...' && read -k1" -fi +tmux bind-key "${THUMBS_KEY}" run-shell -b /usr/share/thumbs/tmux-thumbs.sh -- 2.32.0