Let the user choose the installation method

This commit is contained in:
Ferran Basora 2022-02-03 20:37:25 +00:00
parent 7e553af99f
commit b56e9f1099
2 changed files with 64 additions and 44 deletions

View File

@ -37,13 +37,24 @@ more with `--regexp` parameter.
[![demo](https://asciinema.org/a/232775.png?ts=1)](https://asciinema.org/a/232775?autoplay=1)
## Prerequisites
## Using Tmux Plugin Manager
You can add this line to your list of [TPM](https://github.com/tmux-plugins/tpm) plugins in `.tmux.conf`:
```
set -g @plugin 'fcsonline/tmux-thumbs'
run-shell ~/.tmux/plugins/tmux-thumbs/tmux-thumbs.tmux
```
To be able to install the plugin just hit <kbd>prefix</kbd> + <kbd>I</kbd>. You should now be able to use
the plugin!
## Installation checking out the source code
`tmux-thumbs` is written in Rust. You will need `rustc` version 1.35.0 or higher. The
recommended way to install Rust is from the official [download page](https://rustup.rs/).
## Tmux integration
Clone the repo:
```
@ -69,19 +80,6 @@ Reload TMUX conf by running:
tmux source-file ~/.tmux.conf
```
## Using Tmux Plugin Manager
You can add this line to your list of [TPM](https://github.com/tmux-plugins/tpm) plugins in `.tmux.conf`:
```
set -g @plugin 'fcsonline/tmux-thumbs'
run-shell ~/.tmux/plugins/tmux-thumbs/tmux-thumbs.tmux
```
To be able to install the plugin just hit <kbd>prefix</kbd> + <kbd>I</kbd>. You should now be able to use
the plugin!
## Configuration
If you want to customize how is shown your tmux-thumbs hints those all available

View File

@ -39,10 +39,8 @@ else
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. If you have Rust preinstalled, we will try to
compile the binary from source. Otherwise, a prebuild binary for your platform will be used.
because the binary is not present. We are going to proceed with the
installation.
Do you want to continue?
@ -53,26 +51,48 @@ fi
read -rs -n 1
if ! [ -x "$(command -v cargo)" ]; then
platform="$(uname -s) $(uname -m)"
cat << EOF
echo " Rust is not installed! Trying to install ${platform} binary..."
Which format do you prefer for installation?
1) Compile: will use cargo to compile tmux-thumbs. It requires Rust.
2) Download: will download a precompiled binary for your system.
EOF
select opt in "Compile" "Download"; do
case $opt in
Compile|1)
if ! [ -x "$(command -v cargo)" ]; then
echo '❌ Rust is not installed!'
exit 1
fi
echo ' Compiling tmux-thumbs, be patient:'
cargo build --release --target-dir=target
break;;
Download|2)
platform="$(uname -s)_$(uname -m)"
echo " Downloading ${platform} binary..."
sources=$(curl -s "https://api.github.com/repos/fcsonline/tmux-thumbs/releases/latest" | grep browser_download_url)
case $platform in
"Darwin x86_64")
Darwin_x86_64)
url=$(echo "${sources}" | grep -o 'https://.*darwin.zip' | uniq)
curl -sL "${url}" | bsdtar -xf - thumbs tmux-thumbs
;;
"Linux x86_64")
Linux_x86_64)
url=$(echo "${sources}" | grep -o 'https://.*linux-musl.tar.gz' | uniq)
curl -sL "${url}" | tar -zxf - thumbs tmux-thumbs
;;
*)
echo "Unknown platform: $platform"
echo "❌ Unknown platform: ${platform}"
exit 1
;;
esac
@ -80,10 +100,12 @@ if ! [ -x "$(command -v cargo)" ]; then
chmod +x thumbs tmux-thumbs
mkdir -p target/release
mv thumbs tmux-thumbs target/release
else
echo ' Compiling tmux-thumbs, be patient:'
cargo build --release --target-dir=target
fi
break;;
*)
echo "❌ Ouh? Choose an available option."
esac
done
cat << EOF
Installation complete! 💯