dotfiles/extras.sh

151 lines
2.5 KiB
Bash
Raw Normal View History

2021-12-08 09:38:24 -06:00
#! /usr/bin/env bash
# script to install the extra needed tools programmatically
# add command line flags and function to govern install?
MAMBAFORGE_RELEASE="https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh"
MAMBAFORGE_INSTALLER="Mambaforge-Linux-x86_64.sh"
help() {
2022-07-06 11:55:14 -05:00
cat <<EOF
2021-12-08 09:38:24 -06:00
extras downloaders
by default will download all packages listed below
usage: $0 [OPTIONS]
--help Show this message
--force Overwrite current installations
To install a subset of these
use any of the package specific flag:
--fzf
--nvm
--mambaforge
EOF
}
for opt in "$@"; do
2022-07-06 11:55:14 -05:00
case $opt in
--help)
help
exit 0
;;
--force) force=1 ;;
--fzf) fzf=1 ;;
--mambaforge) mamba=1 ;;
*)
echo "unknown option: $opt"
help
exit 1
;;
esac
2021-12-08 09:38:24 -06:00
done
check_existing() {
2022-07-06 11:55:14 -05:00
pkg=$1
install_dir=$2
declare -n skip_out=$3
if [ -d "$install_dir" ]; then
echo "found existing $pkg installation"
if [[ "$force" ]]; then
echo "removing previous installation"
rm -rf $install_dir
skip_out=0
else
skip_out=1
fi
else
skip_out=0
fi
2021-12-08 09:38:24 -06:00
}
ask() {
2022-07-06 11:55:14 -05:00
while true; do
read -p "$1 ([y]/n) " -r
REPLY=${REPLY:-"y"}
if [[ $REPLY =~ ^[Yy]$ ]]; then
return 1
elif [[ $REPLY =~ ^[Nn]$ ]]; then
return 0
fi
done
2021-12-08 09:38:24 -06:00
}
install_fzf() {
2022-07-06 11:55:14 -05:00
echo "##############"
echo installing fzf
echo "##############"
2021-12-08 09:38:24 -06:00
2022-07-06 11:55:14 -05:00
check_existing "fzf" "$HOME/.fzf" skip
2021-12-08 09:38:24 -06:00
2022-07-06 11:55:14 -05:00
if [[ $skip -eq 1 ]]; then
echo "remove your previous installation or rerun with --force"
return
fi
2021-12-08 09:38:24 -06:00
2022-07-06 11:55:14 -05:00
echo "installing fzf using git"
2021-12-08 09:38:24 -06:00
2022-07-06 11:55:14 -05:00
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
2022-08-30 23:08:41 -05:00
~/.fzf/install --bin
2021-12-08 09:38:24 -06:00
}
install_mambaforge() {
2022-07-06 11:55:14 -05:00
echo "#####################"
echo installing mambaforge
echo "#####################"
2021-12-08 09:38:24 -06:00
2022-07-06 11:55:14 -05:00
check_existing "mambaforge" "$HOME/mambaforge" skip
2021-12-08 09:38:24 -06:00
2022-07-06 11:55:14 -05:00
if [[ $skip -eq 1 ]]; then
echo "remove your previous installation or rerun with --force"
return
fi
2021-12-08 09:38:24 -06:00
2022-07-06 11:55:14 -05:00
echo "fetching install script from github"
2021-12-08 09:38:24 -06:00
2022-07-06 11:55:14 -05:00
current_dir=$PWD
2021-12-08 09:38:24 -06:00
2022-07-06 11:55:14 -05:00
cd ~/
2021-12-08 09:38:24 -06:00
2022-07-06 11:55:14 -05:00
wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh
bash "$MAMBAFORGE_INSTALLER" -s
rm "$MAMBAFORGE_INSTALLER"
2021-12-08 09:38:24 -06:00
2022-07-06 11:55:14 -05:00
echo "cleaning up installer"
2021-12-08 09:38:24 -06:00
2022-07-06 11:55:14 -05:00
cd $current_dir
2021-12-08 09:38:24 -06:00
}
install_all() {
2022-07-06 11:55:14 -05:00
echo "installing all packages..."
echo
install_fzf
echo
install_mambaforge
2021-12-08 09:38:24 -06:00
}
echo "#################"
2022-07-06 11:55:14 -05:00
echo EXTRAS DOWNLOADER
2021-12-08 09:38:24 -06:00
echo "#################"
echo
2022-07-06 11:55:14 -05:00
if [ $# -eq 0 ]; then
install_all
exit
2021-12-08 09:38:24 -06:00
fi
if [ "$fzf" ]; then
2022-07-06 11:55:14 -05:00
install_fzf
2021-12-08 09:38:24 -06:00
fi
2022-07-06 11:55:14 -05:00
if [ "$mamba" ]; then
install_mambaforge
2021-12-08 09:38:24 -06:00
fi
echo "FINISHED!"