Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New environment variable for the installation #133

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ 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!
To be able to install the plugin, just hit <kbd>prefix</kbd> + <kbd>I</kbd>. A fancy installation
process will appear. Follow the described steps, and you should now be able to use the plugin!

Note: If you always choose the same method during the installation process (Ex. Because you use this
plugin in an immutable environment), you can pass the `TMUX_THUMBS_INSTALLATION` environment variable
to choose your desired approach. Valid values for this environment variable are `compile` or `download`.

## Installation checking out the source code

Expand Down
102 changes: 64 additions & 38 deletions tmux-thumbs-install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -Eeu -o pipefail
set -Ee -o pipefail

# Removing the binary to make this script idempotent
rm -rf target/release/thumbs
Expand Down Expand Up @@ -49,7 +49,9 @@ EOF

fi

read -rs -n 1
if [[ -z "${TMUX_THUMBS_INSTALLATION}" ]]; then
read -rs -n 1
fi

cat << EOF

Expand All @@ -60,59 +62,83 @@ cat << EOF

EOF

select opt in "Compile" "Download"; do
case $opt in
Compile|1)
function compile () {
if ! [ -x "$(command -v cargo)" ]; then
echo '❌ Rust is not installed!'
exit 1
fi

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
}

echo ' Compiling tmux-thumbs, be patient:'
cargo build --release --target-dir=target
function download () {
platform="$(uname -s)_$(uname -m)"

break;;
Download|2)
platform="$(uname -s)_$(uname -m)"
echo " Downloading ${platform} binary..."

echo " Downloading ${platform} binary..."
sources=$(curl -s "https://api.github.com/repos/fcsonline/tmux-thumbs/releases/latest" | grep browser_download_url)

sources=$(curl -s "https://api.github.com/repos/fcsonline/tmux-thumbs/releases/latest" | grep browser_download_url)
case $platform in
Darwin_x86_64)
url=$(echo "${sources}" | grep -o 'https://.*darwin.zip' | uniq)
curl -sL "${url}" | bsdtar -xf - thumbs tmux-thumbs

case $platform in
Darwin_x86_64)
url=$(echo "${sources}" | grep -o 'https://.*darwin.zip' | uniq)
curl -sL "${url}" | bsdtar -xf - thumbs tmux-thumbs
;;
Linux_x86_64)
url=$(echo "${sources}" | grep -o 'https://.*linux-musl.tar.gz' | uniq)
curl -sL "${url}" | tar -zxf - thumbs tmux-thumbs

;;
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}"
read -rs -n 1
echo " Press any key to close this pane..."
exit 1
;;
esac

;;
*)
echo "❌ Unknown platform: ${platform}"
read -rs -n 1
echo " Press any key to close this pane..."
exit 1
;;
esac
chmod +x thumbs tmux-thumbs
mkdir -p target/release
mv thumbs tmux-thumbs target/release
}

if [[ -z "${TMUX_THUMBS_INSTALLATION}" ]]; then
select action in "Compile" "Download"; do
case $action in
Compile|1)
compile

break;;
Download|2)
download

break;;
*)
echo "❌ Ouh? Choose an available option."
esac
done
else
case $TMUX_THUMBS_INSTALLATION in
Compile|compile|1)
compile

chmod +x thumbs tmux-thumbs
mkdir -p target/release
mv thumbs tmux-thumbs target/release
;;
Download|download|2)
download

break;;
;;
*)
echo "❌ Ouh? Choose an available option."
esac
done
fi

cat << EOF
Installation complete! 💯

Press any key to close this pane...
EOF

read -rs -n 1
if [[ -z "${TMUX_THUMBS_INSTALLATION}" ]]; then
read -rs -n 1
fi