From a32499fadf94cc5204def8cc1a3d7c66a744f31d Mon Sep 17 00:00:00 2001 From: Ferran Basora Date: Sun, 26 Dec 2021 19:15:07 +0000 Subject: [PATCH] Improve the installation process Many people are struggling with the installation process because is not giving enough feedback. This commit improves this. --- tmux-thumbs-install.sh | 55 ++++++++++++++++++++++++++++++++++++++++++ tmux-thumbs.sh | 7 ++++++ tmux-thumbs.tmux | 6 ----- 3 files changed, 62 insertions(+), 6 deletions(-) create mode 100755 tmux-thumbs-install.sh diff --git a/tmux-thumbs-install.sh b/tmux-thumbs-install.sh new file mode 100755 index 0000000..2bd4cde --- /dev/null +++ b/tmux-thumbs-install.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -Eeu -o pipefail + +# Removing the binary to make this script idempotent +rm -rf target/release/thumbs + +clear + +cat << EOF + + █████ █████ █████ █████ + ░░███ ░░███ ░░███ ░░███ + ███████ █████████████ █████ ████ █████ █████ ███████ ░███████ █████ ████ █████████████ ░███████ █████ +░░░███░ ░░███░░███░░███ ░░███ ░███ ░░███ ░░███ ██████████░░░███░ ░███░░███ ░░███ ░███ ░░███░░███░░███ ░███░░███ ███░░ + ░███ ░███ ░███ ░███ ░███ ░███ ░░░█████░ ░░░░░░░░░░ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███░░█████ + ░███ ███ ░███ ░███ ░███ ░███ ░███ ███░░░███ ░███ ███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░░░░███ + ░░█████ █████░███ █████ ░░████████ █████ █████ ░░█████ ████ █████ ░░████████ █████░███ █████ ████████ ██████ + ░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░░░░ ░░░░░░ + + + +It looks like this is the first time you are executing tmux-thumbs +because the binary is not present. + +We are going to proceed with the installation. Remember that Rust is +a prerequisite to being able to build tmux-thumbs. + +Do you want to continue? + +Press any key to continue... +EOF + +read -s -n 1 + +if ! [ -x "$(command -v cargo)" ]; then + echo 'Rust is not installed! ❌' >&2 + echo 'Press any key to install it' >&2 + + read -s -n 1 + + # This installation es provided by the official https://rustup.rs documentation + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +fi + +echo 'Compiling tmux-thumbs, be patient:' + +cargo build --release --target-dir=target + +cat << EOF +Installation complete! 💯 + +Press any key to close this pane... +EOF + +read -s -n 1 diff --git a/tmux-thumbs.sh b/tmux-thumbs.sh index 9000c31..165841d 100755 --- a/tmux-thumbs.sh +++ b/tmux-thumbs.sh @@ -3,6 +3,13 @@ set -Eeu -o pipefail CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +BINARY="${CURRENT_DIR}/target/release/thumbs" + +if [ ! -f "$BINARY" ]; then + tmux split-window "cd ${CURRENT_DIR} && bash ./tmux-thumbs-install.sh" + exit +fi + function get-opt-value() { tmux show -vg "@thumbs-${1}" 2> /dev/null } diff --git a/tmux-thumbs.tmux b/tmux-thumbs.tmux index 16179e6..949527d 100755 --- a/tmux-thumbs.tmux +++ b/tmux-thumbs.tmux @@ -9,9 +9,3 @@ THUMBS_KEY=${THUMBS_KEY:-$DEFAULT_THUMBS_KEY} tmux set-option -ag command-alias "thumbs-pick=run-shell -b ${CURRENT_DIR}/tmux-thumbs.sh" tmux bind-key "${THUMBS_KEY}" thumbs-pick - -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