fix setup script
This commit is contained in:
parent
752fe71647
commit
a4fc0b8cdc
@ -1,4 +1,4 @@
|
|||||||
asdfInstall(){
|
asdf_install(){
|
||||||
. "$HOME/.asdf/asdf.sh"
|
. "$HOME/.asdf/asdf.sh"
|
||||||
if [ "$(which asdf)" = "" ]; then
|
if [ "$(which asdf)" = "" ]; then
|
||||||
echo "Asdf not installed"
|
echo "Asdf not installed"
|
||||||
@ -11,6 +11,3 @@ asdfInstall(){
|
|||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[[ "${1}" != "--source-only" ]] && asdfInstall "${@}"
|
|
||||||
|
63
.dotfiles/helpers/installer.sh
Normal file → Executable file
63
.dotfiles/helpers/installer.sh
Normal file → Executable file
@ -1,35 +1,40 @@
|
|||||||
isInstalled() {
|
#!/bin/bash
|
||||||
if [ "$(which $1)" != "" ]; then
|
|
||||||
return 0
|
# Function to check if a command exists
|
||||||
fi
|
command_exists() {
|
||||||
return 1
|
command -v "$1" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
installOptional() {
|
|
||||||
echo "install optional '$*'"
|
|
||||||
|
|
||||||
# Check if any of the listed programs are installed
|
package_manager=$1
|
||||||
# if not install the first one;
|
# Detect the package manager
|
||||||
for prog in "$@"; do
|
if command_exists apt-get; then
|
||||||
if isInstalled $prog; then
|
package_manager="apt"
|
||||||
echo "$prog is installed"
|
elif command_exists yum; then
|
||||||
break
|
package_manager="yum"
|
||||||
fi
|
elif command_exists pacman; then
|
||||||
done
|
package_manager="pacman"
|
||||||
|
else
|
||||||
|
echo "Unsupported package manager. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
install $1
|
# Function to install packages based on the package manager
|
||||||
|
install_package() {
|
||||||
|
|
||||||
|
case $package_manager in
|
||||||
|
apt)
|
||||||
|
sudo apt-get install -y $1
|
||||||
|
;;
|
||||||
|
yum)
|
||||||
|
sudo yum install -y $1
|
||||||
|
;;
|
||||||
|
pacman)
|
||||||
|
sudo pacman -S --noconfirm $1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported package manager: $package_manager"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
install() {
|
|
||||||
# Check if program is already installed
|
|
||||||
if isInstalled $1; then
|
|
||||||
echo " ✓ $1 is already installed"
|
|
||||||
else
|
|
||||||
echo " - installing $1 ..."
|
|
||||||
sudo apt-get install $1 -y >/dev/null
|
|
||||||
echo " ✓ finished"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
[[ "${1}" != "--source-only" ]] && install "${@}"
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
linkFile() {
|
|
||||||
#Move old file
|
|
||||||
if [ -f "$HOME/$1" ]; then
|
|
||||||
echo " - moving old file to $1_bak"
|
|
||||||
mv "$HOME/$1" "$HOME/$1_bak"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo " - linking $1 --> $HOME/$1"
|
|
||||||
|
|
||||||
ln -s "$(pwd)/configs/$1" "$HOME/$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
[[ "${1}" != "--source-only" ]] && linkFile "${@}"
|
|
@ -104,5 +104,3 @@ function multiselect() {
|
|||||||
|
|
||||||
eval $retval='("${selected[@]}")'
|
eval $retval='("${selected[@]}")'
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ "${1}" != "--source-only" ]] && multiselect "${@}"
|
|
||||||
|
@ -7,5 +7,3 @@ prompt() {
|
|||||||
*) echo "invalid" ;;
|
*) echo "invalid" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ "${1}" != "--source-only" ]] && prompt "${@}"
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
if [ -f "$HOME/.config/nvim/init.lua" ]; then
|
|
||||||
echo " - moving old file to init.lua.BAK"
|
|
||||||
mv "$HOME/.config/nvim/init.lua" "$HOME/.config/nvim/init.lua.BAK"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo " - linking init.vim --> init.vim"
|
|
||||||
mkdir -p $HOME/.config/nvim
|
|
||||||
ln -s "$HOME/.dotfiles/configs/init.lua" "$HOME/.config/nvim/init.lua"
|
|
||||||
ln -s "$HOME/.dotfiles/configs/lua" "$HOME/.config/nvim/lua"
|
|
@ -1,8 +0,0 @@
|
|||||||
FOLDER=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
|
|
||||||
if [ -s $FOLDER ]; then
|
|
||||||
echo " ✓ zsh-autosuggestions is already installed"
|
|
||||||
else
|
|
||||||
echo " - cloning github.com/zsh-users/zsh-autosuggestions into $FOLDER"
|
|
||||||
git clone --quiet https://github.com/zsh-users/zsh-autosuggestions $FOLDER > /dev/null
|
|
||||||
echo " - finished"
|
|
||||||
fi
|
|
@ -1,17 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cd "$(dirname "$0")"
|
|
||||||
|
|
||||||
INTERACTIVE="false"
|
INTERACTIVE=false
|
||||||
if [ $- == *i* ]; then
|
if [ -t 0 ] ; then
|
||||||
INTERACTIVE="true"
|
INTERACTIVE=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#Loading all the helper scripts
|
#Loading all the helper scripts
|
||||||
. ./helpers/installer.sh --source-only
|
source ./helpers/installer.sh
|
||||||
. ./helpers/prompt.sh --source-only
|
source ./helpers/prompt.sh
|
||||||
. ./helpers/linker.sh --source-only
|
source ./helpers/multiselect.sh
|
||||||
. ./helpers/multiselect.sh --source-only
|
|
||||||
|
|
||||||
echo "-- welcome to my setup script --"
|
echo "-- welcome to my setup script --"
|
||||||
|
|
||||||
@ -19,20 +17,15 @@ if [ "$(which git)" = "" ] && ["$(which curl)" = ""]; then
|
|||||||
|
|
||||||
echo "-- installing prerequesits (git, curl) --"
|
echo "-- installing prerequesits (git, curl) --"
|
||||||
|
|
||||||
if [ $INTERACTIVE = "true" ]; then
|
if [ $INTERACTIVE = true ]; then
|
||||||
if [ "$(prompt " - do you want to continue")" != "yes" ]; then
|
if [ "$(prompt " - do you want to continue")" != "yes" ]; then
|
||||||
echo " alllrighty then, byyye"
|
echo " alllrighty then, byyye"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
install_package git
|
||||||
|
install_package curl
|
||||||
#Prerequesits
|
|
||||||
echo "-- installing prerequisites --"
|
|
||||||
|
|
||||||
install git
|
|
||||||
install curl
|
|
||||||
|
|
||||||
echo "-----------------------------------"
|
echo "-----------------------------------"
|
||||||
|
|
||||||
@ -59,7 +52,7 @@ for i in "${!OPTIONS_VALUES[@]}"; do
|
|||||||
OPTIONS_STRING+="${OPTIONS_VALUES[$i]} (${OPTIONS_LABELS[$i]});"
|
OPTIONS_STRING+="${OPTIONS_VALUES[$i]} (${OPTIONS_LABELS[$i]});"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $INTERACTIVE = "true" ]; then
|
if [ $INTERACTIVE = true ]; then
|
||||||
multiselect SELECTED "$OPTIONS_STRING":
|
multiselect SELECTED "$OPTIONS_STRING":
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -75,50 +68,40 @@ INST_DENO=${SELECTED[7]}
|
|||||||
INST_HUGO=${SELECTED[8]}
|
INST_HUGO=${SELECTED[8]}
|
||||||
INST_RUST=${SELECTED[9]}
|
INST_RUST=${SELECTED[9]}
|
||||||
|
|
||||||
if [ $INTERACTIVE = "false" ]; then
|
if [ $INTERACTIVE = false ]; then
|
||||||
INST_ZSH=true
|
INST_ZSH=true
|
||||||
INST_ASDF=true
|
INST_ASDF=true
|
||||||
INST_NVIM=true
|
INST_NVIM=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "-----------------------------------"
|
|
||||||
|
|
||||||
echo -e "-- installing programs --"
|
echo -e "-- installing programs --"
|
||||||
[[ "$INST_DRNV" = true ]] && install direnv
|
|
||||||
|
[[ "$INST_DRNV" = true ]] && install_package direnv
|
||||||
if [ "$INST_ASDF" = true ]; then
|
if [ "$INST_ASDF" = true ]; then
|
||||||
|
|
||||||
# Requirements for ASDF
|
# Requirements for ASDF
|
||||||
install gnupg2
|
install_package gnupg2
|
||||||
install unzip
|
install_package unzip
|
||||||
./install/install-asdf.sh
|
$HOME/.dotfiles/install/asdf.sh
|
||||||
|
|
||||||
if [ "$INST_NVIM" = true ]; then
|
if [ "$INST_NVIM" = true ]; then
|
||||||
asdfInstall neovim
|
asdf_install neovim
|
||||||
./install/install-nvim.sh
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ "$INST_NODE" = true ]] && asdfInstall nodejs
|
[[ "$INST_NODE" = true ]] && asdf_install nodejs
|
||||||
[[ "$INST_GO" = true ]] && asdfInstall golang
|
[[ "$INST_GO" = true ]] && asdf_install golang
|
||||||
[[ "$INST_PYTH" = true ]] && asdfInstall python
|
[[ "$INST_PYTH" = true ]] && asdf_install python
|
||||||
[[ "$INST_DENO" = true ]] && asdfInstall deno
|
[[ "$INST_DENO" = true ]] && asdf_install deno
|
||||||
[[ "$INST_HUGO" = true ]] && asdfInstall hugo
|
[[ "$INST_HUGO" = true ]] && asdf_install hugo
|
||||||
[[ "$INST_RUST" = true ]] && asdfInstall rust
|
[[ "$INST_RUST" = true ]] && asdf_install rust
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "-- linking .dotfiles --"
|
|
||||||
|
|
||||||
linkFile .p10k.zsh
|
|
||||||
linkFile .dircolors
|
|
||||||
linkFile .tmux.conf
|
|
||||||
|
|
||||||
if [ "$INST_ZSH" = true ]; then
|
if [ "$INST_ZSH" = true ]; then
|
||||||
echo "-- installing oh-my-zsh --"
|
echo "-- installing oh-my-zsh --"
|
||||||
linkFile .zshrc
|
install_package zsh
|
||||||
install zsh
|
|
||||||
|
|
||||||
zsh $(pwd)/install/oh-my-zsh.sh
|
zsh $HOME/.dotfiles/install/oh-my-zsh.sh
|
||||||
zsh $(pwd)/install/zsh-autosuggestions.sh
|
zsh $HOME/.dotfiles/install/p10k.sh
|
||||||
zsh $(pwd)/install/p10k.sh
|
|
||||||
|
|
||||||
echo "-----------------------------------"
|
echo "-----------------------------------"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user