Improve the installation process

Many people are struggling with the installation process because is not
giving enough feedback.

This commit improves this.
This commit is contained in:
Ferran Basora 2021-12-26 19:15:07 +00:00
parent 8242c04d10
commit a32499fadf
3 changed files with 62 additions and 6 deletions

55
tmux-thumbs-install.sh Executable file
View File

@ -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

View File

@ -3,6 +3,13 @@ set -Eeu -o pipefail
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 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() { function get-opt-value() {
tmux show -vg "@thumbs-${1}" 2> /dev/null tmux show -vg "@thumbs-${1}" 2> /dev/null
} }

View File

@ -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 set-option -ag command-alias "thumbs-pick=run-shell -b ${CURRENT_DIR}/tmux-thumbs.sh"
tmux bind-key "${THUMBS_KEY}" thumbs-pick 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