mirror of
https://github.com/FliegendeWurst/tmux-thumbs.git
synced 2024-11-24 05:45:00 +00:00
feat(install): installation from binary
If cargo exists, use it. Otherwise, if the combination of platform and
architecture has a precompiled binary, then use it.
Thanks @fcsonline for the help 🙇
This commit is contained in:
parent
19f30d7b22
commit
db2a8896c9
@ -22,29 +22,48 @@ cat << EOF
|
|||||||
It looks like this is the first time you are executing tmux-thumbs
|
It looks like this is the first time you are executing tmux-thumbs
|
||||||
because the binary is not present.
|
because the binary is not present.
|
||||||
|
|
||||||
We are going to proceed with the installation. Remember that Rust is
|
We are going to proceed with the installation. If you have Rust preinstalled, we will try to
|
||||||
a prerequisite to being able to build tmux-thumbs.
|
compile the binary from source. Otherwise, a prebuild binary for your platform will be used.
|
||||||
|
|
||||||
Do you want to continue?
|
Do you want to continue?
|
||||||
|
|
||||||
Press any key to continue...
|
Press any key to continue...
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
read -s -n 1
|
read -rs -n 1
|
||||||
|
|
||||||
if ! [ -x "$(command -v cargo)" ]; then
|
if ! [ -x "$(command -v cargo)" ]; then
|
||||||
echo 'Rust is not installed! ❌' >&2
|
platform="$(uname -s) $(uname -m)"
|
||||||
echo 'Press any key to install it' >&2
|
|
||||||
|
|
||||||
read -s -n 1
|
echo "Rust is not installed! Trying to install ${platform} binary..."
|
||||||
|
|
||||||
# This installation es provided by the official https://rustup.rs documentation
|
sources=$(curl -s "https://api.github.com/repos/fcsonline/tmux-thumbs/releases/latest" | grep browser_download_url)
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
case $platform in
|
||||||
|
"Darwin x86_64")
|
||||||
|
url=$(echo "${sources}" | grep -o 'https://.*darwin.zip' | uniq)
|
||||||
|
curl -L "${url}" | bsdtar -xf - thumbs tmux-thumbs
|
||||||
|
|
||||||
|
;;
|
||||||
|
"Linux x86_64")
|
||||||
|
url=$(echo "${sources}" | grep -o 'https://.*linux-musl.tar.gz' | uniq)
|
||||||
|
curl -L "${url}" | tar -zxf - thumbs tmux-thumbs
|
||||||
|
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown platform: $platform"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
chmod +x thumbs tmux-thumbs
|
||||||
|
mkdir -p target/release
|
||||||
|
mv thumbs target/release
|
||||||
|
mv tmux-thumbs target/release
|
||||||
|
else
|
||||||
echo 'Compiling tmux-thumbs, be patient:'
|
echo 'Compiling tmux-thumbs, be patient:'
|
||||||
|
|
||||||
cargo build --release --target-dir=target
|
cargo build --release --target-dir=target
|
||||||
|
fi
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF
|
||||||
Installation complete! 💯
|
Installation complete! 💯
|
||||||
@ -52,4 +71,4 @@ Installation complete! 💯
|
|||||||
Press any key to close this pane...
|
Press any key to close this pane...
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
read -s -n 1
|
read -rs -n 1
|
||||||
|
@ -3,16 +3,12 @@ set -Eeu -o pipefail
|
|||||||
|
|
||||||
# Setup env variables to be compatible with compiled and bundled installations
|
# Setup env variables to be compatible with compiled and bundled installations
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
if [ -d ${CURRENT_DIR}/.git ]; then
|
|
||||||
RELEASE_DIR="${CURRENT_DIR}/target/release"
|
RELEASE_DIR="${CURRENT_DIR}/target/release"
|
||||||
else
|
|
||||||
RELEASE_DIR=${CURRENT_DIR}
|
|
||||||
fi
|
|
||||||
|
|
||||||
BINARY="${RELEASE_DIR}/thumbs"
|
THUMBS_BINARY="${RELEASE_DIR}/thumbs"
|
||||||
|
TMUX_THUMBS_BINARY="${RELEASE_DIR}/tmux-thumbs"
|
||||||
|
|
||||||
if [ ! -f "$BINARY" ]; then
|
if [ ! -f "$THUMBS_BINARY" ]; then
|
||||||
tmux split-window "cd ${CURRENT_DIR} && bash ./tmux-thumbs-install.sh"
|
tmux split-window "cd ${CURRENT_DIR} && bash ./tmux-thumbs-install.sh"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
@ -50,4 +46,4 @@ add-param upcase-command string
|
|||||||
add-param multi-command string
|
add-param multi-command string
|
||||||
add-param osc52 boolean
|
add-param osc52 boolean
|
||||||
|
|
||||||
"${RELEASE_DIR}/tmux-thumbs" "${PARAMS[@]}" || true
|
"${TMUX_THUMBS_BINARY}" "${PARAMS[@]}" || true
|
||||||
|
Loading…
Reference in New Issue
Block a user