VimsCode/vimscode.sh

147 lines
3.9 KiB
Bash
Raw Permalink Normal View History

2025-02-12 12:37:39 +01:00
#!/bin/bash
# Fonction pour gérer l'interruption du script
cleanup() {
printf "\nInterruption du script...\n"
exit 0
}
# Capturer le signal SIGINT (Ctrl+C)
trap cleanup SIGINT
install() {
printf "INSTALLATION DE VIMSCODE\n"
2025-02-12 14:12:24 +01:00
printf 'Installation en cours : [--------------------](0%%)\n'
2025-02-12 12:37:39 +01:00
2025-06-12 13:53:54 +02:00
# Détecter la distribution Linux
if [ -f /etc/os-release ]; then
. /etc/os-release
if [ "$ID" == "debian" ] || [ "$ID" == "ubuntu" ]; then
sudo apt update > /dev/null 2>&1
sudo apt install -y figlet > /dev/null 2>&1
elif [ "$ID" == "fedora" ]; then
sudo dnf install -y figlet > /dev/null 2>&1
elif [ "$ID" == "arch" ] || [ "$ID" == "manjaro" ]; then
sudo pacman -S figlet > /dev/null 2>&1
else
echo "Installation du paquet <figlet> requis."
read -p "Veullez installer le paquet manuellement ? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
read -p "Voulez-vous continuer l'installation ? (y/n) " -n 1 -r
echo
else
echo "Installation annulée."
exit 1
fi
fi
fi
2025-02-12 14:12:24 +01:00
printf 'Installation en cours : [#####---------------](25%%)\n'
2024-08-19 11:57:35 +02:00
2025-02-12 12:37:39 +01:00
if [ ! -d "$HOME/.vim" ]; then
mkdir ~/.vim && mv * ~/.vim
fi
cd ~/.vim && mv vimrc-conf ~/.vimrc && mv vimrc2-conf ~/.vimrc2
cd bundle/ && git clone https://github.com/VundleVim/Vundle.vim.git > /dev/null 2>&1
sudo mv ~/.vim/vimscode.sh /bin/
2025-02-12 14:12:24 +01:00
printf 'Installation en cours : [##########----------](50%%)\n'
2024-08-19 11:57:35 +02:00
2025-02-12 14:12:24 +01:00
printf "Utilisez-vous bash ou zsh ?\n"
2024-08-19 11:57:35 +02:00
read -r term
if [ "$term" = "bash" ]; then
2025-02-12 12:37:39 +01:00
if ! grep -q 'alias vimscode="/bin/vimscode.sh"' ~/.bashrc; then
2024-08-19 11:57:35 +02:00
echo 'alias vimscode="/bin/vimscode.sh"' >> ~/.bashrc
fi
else
2025-02-12 12:37:39 +01:00
if ! grep -q 'alias vimscode="/bin/vimscode.sh"' ~/.zshrc; then
2024-08-19 11:57:35 +02:00
echo 'alias vimscode="/bin/vimscode.sh"' >> ~/.zshrc
fi
fi
2025-02-12 12:37:39 +01:00
2025-02-12 14:12:24 +01:00
printf 'Configuration en cours : [###############-----](75%%)\n'
2024-08-19 11:57:35 +02:00
vim -u ~/.vimrc2 -c PluginInstall -c q -c q > /dev/null 2>&1
rm -rf ~/.vimrc2
2025-02-12 14:55:33 +01:00
rm -rf ../VimsCode
2025-02-12 14:12:24 +01:00
printf 'Configuration en cours : [####################](100%%)\n'
2025-02-12 12:37:39 +01:00
printf "Installation terminée.\n"
2024-08-19 11:57:35 +02:00
}
2025-02-12 12:37:39 +01:00
# Fonction pour la mise à jour de VimsCode
maj() {
printf "Mise à jour en cours...\n"
2025-02-12 14:12:24 +01:00
printf 'Début de la mise à jour : [-----------------](0%%)\n'
2025-02-12 12:37:39 +01:00
2025-02-12 14:26:08 +01:00
if [ -d "$HOME/VimsCode" ]; then
rm -rf VimsCode
fi
2025-02-12 12:37:39 +01:00
rm -rf ~/.vim ~/.vimrc
2025-02-12 14:12:24 +01:00
git clone https://git.cohabit.fr/bastien/VimsCode.git > /dev/null 2>&1
cd VimsCode
2024-08-19 11:57:35 +02:00
2025-02-12 12:37:39 +01:00
if [ ! -d "$HOME/.vim" ]; then
mkdir ~/.vim && mv * ~/.vim
fi
cd ~/.vim && mv vimrc-conf ~/.vimrc && mv vimrc2-conf ~/.vimrc2
cd bundle/ && git clone https://github.com/VundleVim/Vundle.vim.git > /dev/null 2>&1
sudo mv ~/.vim/vimscode.sh /bin/
2025-02-12 14:12:24 +01:00
printf 'Mise à jour en cours : [#####---------------](25%%)\n'
2024-08-19 11:57:35 +02:00
2025-02-12 14:12:24 +01:00
printf "Utilisez-vous bash ou zsh ?\n"
2024-08-19 11:57:35 +02:00
read -r term
if [ "$term" = "bash" ]; then
2025-02-12 12:37:39 +01:00
if ! grep -q 'alias vimscode="/bin/vimscode.sh"' ~/.bashrc; then
2024-08-19 11:57:35 +02:00
echo 'alias vimscode="/bin/vimscode.sh"' >> ~/.bashrc
fi
else
2025-02-12 12:37:39 +01:00
if ! grep -q 'alias vimscode="/bin/vimscode.sh"' ~/.zshrc; then
2024-08-19 11:57:35 +02:00
echo 'alias vimscode="/bin/vimscode.sh"' >> ~/.zshrc
fi
fi
2025-02-12 12:37:39 +01:00
2025-02-12 14:12:24 +01:00
printf 'Mise à jour en cours : [##########----------](50%%)\n'
2024-08-19 11:57:35 +02:00
vim -u ~/.vimrc2 -c PluginInstall -c q -c q > /dev/null 2>&1
rm -rf ~/.vimrc2
2025-02-12 14:12:24 +01:00
printf 'Mise à jour en cours : [###############-----](75%%)\n'
2024-08-19 11:57:35 +02:00
2025-02-12 15:16:19 +01:00
rm -rf ../../VimsCode
2025-02-12 14:44:20 +01:00
2025-02-12 14:12:24 +01:00
printf 'Mise à jour fini : [####################](100%%)\n'
2025-02-12 12:37:39 +01:00
printf "Mise à jour terminée.\n"
2024-08-19 11:57:35 +02:00
}
2025-02-12 12:37:39 +01:00
# Gestion des arguments
case "$1" in
-maj)
maj
;;
-install)
install
;;
-a | -arduino)
vim -p "$2" ~/.vim/help/En/help-arduino
;;
-e | -esp)
vim -p "$2" ~/.vim/help/En/help-esp32
;;
-p | -platform.io)
vim -p "$2" ~/.vim/help/En/help-platform.io
;;
'')
cat ~/.vim/help/help-vimscode
;;
*)
2025-02-12 12:39:55 +01:00
echo "Commande invalide"
;;
esac