myhome/.config/nvim/installer.sh

189 lines
5.7 KiB
Bash
Raw Normal View History

2022-04-20 20:58:25 +02:00
#!/bin/bash
# shellcheck disable=2045,2086
2022-04-20 20:58:25 +02:00
2023-03-25 13:43:24 +01:00
ZSHFOLDER=$HOME/.config/zsh
CONFIG="$HOME/.config"
# Colours
RED='\033[0;31m'
GREEN='\033[0;0;32m'
NC='\033[0m'
2022-07-18 21:08:52 +02:00
function timestamp() {
2023-03-25 13:43:24 +01:00
echo -e "${GREEN}[+]${NC} $(date +'%F %T') [INFO] $*"
2022-07-18 21:08:52 +02:00
}
function err() {
2023-03-25 13:43:24 +01:00
echo -e "${RED}[-] $(date +'%F %T') [ERROR] $*${NC}" >&2
2022-07-18 21:08:52 +02:00
}
function command_start() {
timestamp "Command $* has been started."
if ! "$*"; then
err "Command $* went wrong."
2023-03-25 13:43:24 +01:00
exit
2022-07-18 21:08:52 +02:00
fi
timestamp "Command $* has been ended."
}
function update_pip() {
# Update the pip
python3 -m pip install --upgrade pip --user
}
function install_neovim_module_for_python() {
# Python module in neovim
2023-03-25 13:43:24 +01:00
pip3 install neovim --pre --user --force --quiet
}
2022-07-18 21:08:52 +02:00
function install_pyright() {
# Install pyright
2023-03-25 13:43:24 +01:00
sudo npm -s -g i pyright --force
2022-07-18 21:08:52 +02:00
}
function install_bash-language-server() {
# Install bash-language-server
2023-03-25 13:43:24 +01:00
sudo npm -s -g i bash-language-server --force
2022-07-18 21:08:52 +02:00
}
function install_yaml-language-server() {
# Install yaml-language-server
2023-03-25 13:43:24 +01:00
sudo npm -s -g i yaml-language-server --force
2022-07-18 21:08:52 +02:00
}
function install_shfmt() {
# Install shfmt
GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@latest
}
function install_terraform() {
# Install terraform and terraform-ls
GO111MODULE=on go install github.com/hashicorp/terraform@latest
GO111MODULE=on go install github.com/hashicorp/terraform-ls@latest
if [[ "$(uname)" == "Darwin" ]]; then
2023-03-25 13:43:24 +01:00
brew install tflint -q
2023-04-07 16:05:32 +02:00
brew install tfenv -q
else
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
fi
}
function install_terragrunt() {
# Install terragrunt
if [[ "$(uname)" == "Darwin" ]]; then
2023-03-25 13:43:24 +01:00
brew install terragrunt -q
else
wget https://github.com/gruntwork-io/terragrunt/releases/latest/download/terragrunt_linux_amd64 -O $HOME/.local/bin/terragrunt
chmod +x $HOME/.local/bin/terragrunt
fi
}
function install_shellcheck() {
# Install shellcheck
if [[ "$(uname)" == "Darwin" ]]; then
2023-03-25 13:43:24 +01:00
brew install shellcheck -q
else
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
fi
}
2022-07-18 21:08:52 +02:00
function install_gopls() {
# Install gopls
GO111MODULE=on go install golang.org/x/tools/gopls@latest
}
function install_black() {
# Install black
2023-03-25 13:43:24 +01:00
pip3 install black --pre --user --force --quiet
}
function install_ansible() {
# Install Ansible
2023-03-25 13:43:24 +01:00
pip3 install ansible ansible-lint ansible-core --pre --user --force --quiet
2022-07-18 21:08:52 +02:00
}
2022-10-09 20:46:39 +02:00
function install_ansible-language-server() {
# Install ansible-language-server
2023-03-25 13:43:24 +01:00
sudo npm -s -g i @ansible/ansible-language-server --force
sudo npm -s -g i yaml-language-server --force
2022-10-09 20:46:39 +02:00
}
2022-11-24 13:57:23 +01:00
function install_meraki_ansible() {
# Install python, ansible module for meraki
2022-11-24 13:57:23 +01:00
ansible-galaxy collection install cisco.meraki --force
2023-03-25 13:43:24 +01:00
pip3 install meraki --user --force --quiet
2022-11-24 13:57:23 +01:00
}
function install_azure_cli() {
# Install azure_cli
2023-03-25 13:43:24 +01:00
pip3 install azure-cli --pre --user --force --quiet
}
function install_awscli() {
# Install awscli
2023-03-25 13:43:24 +01:00
pip3 install awscli --pre --user --force --quiet
}
2023-03-25 13:43:24 +01:00
function update() {
if [ -d $CONFIG/fzf ]; then
FOLDER="$CONFIG/fzf"
cd $FOLDER || err "Folder $FOLDER has been NOT found"
git pull -q && timestamp "Pulling the $FOLDER configuration"
else
FOLDER="$CONFIG/fzf"
git clone https://github.com/junegunn/fzf.git $FOLDER && timestamp "Cloning the FZF"
git pull -q && timestamp "Pulling the $FOLDER configuration"
fi
if [ ! -d $ZSHFOLDER/aws ]; then
curl -s https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/aws/aws.plugin.zsh \
-o "$ZSHFOLDER"/aws/aws.plugin.zsh &&
timestamp "Downloaded the newest version of aws plugin for zsh"
curl -s https://raw.githubusercontent.com/Azure/azure-cli/dev/az.completion \
-o "$ZSHFOLDER"/azure-cli/az.completion &&
timestamp "Downloaded the newest version of az plugin for zsh"
mkdir -p "$ZSHFOLDER/azure-cli" "$ZSHFOLDER/aws"
cd $ZSHFOLDER || err "Folder $ZSHFOLDER has been NOT found"
git clone https://github.com/popstas/zsh-command-time.git &&
timestamp "Cloning the zsh-command-time"
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git &&
timestamp "Cloning the zsh-syntax-highlighting"
git clone https://github.com/zsh-users/zsh-autosuggestions.git &&
timestamp "Cloning the zsh-autosuggestions"
fi
for i in $(ls $ZSHFOLDER); do
FOLDER="$ZSHFOLDER/$i"
if [ -d "$FOLDER/.git" ]; then
cd "$FOLDER" || err "Folder $FOLDER has been NOT found"
git pull -q && timestamp "Pulling the $FOLDER configuration"
fi
done
2023-03-25 13:43:24 +01:00
curl -s https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/aws/aws.plugin.zsh -o "$ZSHFOLDER"/aws/aws.plugin.zsh && timestamp "Downloaded the newest version of aws plugin for zsh"
curl -s https://raw.githubusercontent.com/Azure/azure-cli/dev/az.completion -o "$ZSHFOLDER"/azure-cli/az.completion && timestamp "Downloaded the newest version of az plugin for zsh"
}
2022-07-18 21:08:52 +02:00
function main() {
command_start update_pip
2022-07-18 21:08:52 +02:00
command_start install_pyright
command_start install_bash-language-server
command_start install_yaml-language-server
command_start install_ansible-language-server
command_start install_shfmt
command_start install_shellcheck
2022-07-18 21:08:52 +02:00
command_start install_gopls
command_start install_terraform
command_start install_terragrunt
command_start install_azure_cli
2022-07-18 21:08:52 +02:00
command_start install_black
command_start install_ansible
2022-11-24 13:57:23 +01:00
command_start install_meraki_ansible
2023-03-25 13:43:24 +01:00
command_start update
2022-07-18 21:08:52 +02:00
}
main