Installation using cargo install

This commit is contained in:
FliegendeWurst 2021-04-17 13:14:57 +02:00
parent 7eb549875d
commit 79ee5abc7c
3 changed files with 11 additions and 10 deletions

View File

@ -209,12 +209,19 @@ impl<'a> Swapper<'a> {
"".to_string()
};
let cargo_home = option_env!("CARGO_HOME");
let binary = if let Some(home) = cargo_home {
format!("{}/bin/thumbs", home)
} else {
format!("{}/target/release/thumbs", self.dir)
};
let pane_command = format!(
"tmux capture-pane -et {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 -et {active_pane_id} -p{scroll_params} | tail -n {height} | {binary} -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,
binary = binary,
tmp = TMP_FILE,
args = args.join(" "),
zoom_command = zoom_command,

View File

@ -35,4 +35,4 @@ add-param command string
add-param upcase-command string
add-param osc52 boolean
"${CURRENT_DIR}/target/release/tmux-thumbs" "${PARAMS[@]}" || true
"$TMUX_THUMBS_BINARY" "${PARAMS[@]}"

View File

@ -7,10 +7,4 @@ 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 "TMUX_THUMBS_BINARY=$HOME/.cache/cargo/bin/tmux-thumbs ${CURRENT_DIR}/tmux-thumbs.sh"