Correction du echo + ajout du ctrl c

This commit is contained in:
bastien 2025-02-12 12:37:39 +01:00
parent d9aa5f526e
commit 6a8ba8f85a

View file

@ -1,85 +1,115 @@
install(){
echo -e "INSTALLATION DE VIMSCODE\r"
echo -e 'Installation en cours : [--------------------](0%)\r'
#!/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"
printf 'Installation en cours : [--------------------](0%%)\r'
sudo apt update > /dev/null 2>&1
sudo apt install elinks figlet -y > /dev/null 2>&1
echo -e 'Installation en cours : [#####---------------](25%)\r'
printf 'Installation en cours : [#####---------------](25%%)\r'
mkdir ~/.vim && mv * ~/.vim
cd ~/.vim && mv vimrc-conf ~/.vimrc && mv vimrc2-conf ~/.vimrc2
cd ~/.vim/bundle/ && git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim > /dev/null 2>&1
sudo mv ~/.vim/install.sh /bin/
echo -e 'Installation en cours : [##########----------](50%)\r'
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/
printf 'Installation en cours : [##########----------](50%%)\r'
echo "Utilisez-vous bash ou zsh ?"
printf "Utilisez-vous bash ou zsh ? "
read -r term
if [ "$term" = "bash" ]; then
if ! cat ~/.bashrc | grep -q 'alias vimscode="/bin/vimscode.sh"'; then
if ! grep -q 'alias vimscode="/bin/vimscode.sh"' ~/.bashrc; then
echo 'alias vimscode="/bin/vimscode.sh"' >> ~/.bashrc
fi
else
if ! cat ~/.zshrc | grep -q 'alias vimscode="/bin/vimscode.sh"'; then
if ! grep -q 'alias vimscode="/bin/vimscode.sh"' ~/.zshrc; then
echo 'alias vimscode="/bin/vimscode.sh"' >> ~/.zshrc
fi
fi
echo -e 'Configuration en cours : [###############-----](75%)\r'
printf 'Configuration en cours : [###############-----](75%%)\r'
vim -u ~/.vimrc2 -c PluginInstall -c q -c q > /dev/null 2>&1
rm -rf ~/.vimrc2
echo -e 'Configuration en cours : [####################](100%)\r'
printf 'Configuration en cours : [####################](100%%)\r\n'
echo "Installation terminée."
printf "Installation terminée.\n"
}
# Fonction pour la mises a jour de Vimscode
maj(){
echo -e "Mise à jour en cours..."
echo -e 'Début de la mise à jour : [-----------------](0%)\r'
rm -rf ~/.vim ~/.vimrc
# Fonction pour la mise à jour de VimsCode
maj() {
printf "Mise à jour en cours...\n"
printf 'Début de la mise à jour : [-----------------](0%%)\r'
rm -rf ~/.vim ~/.vimrc
git clone https://git.cohabit.fr/bastien/VimsCode.git > /dev/null 2>&1 && cd VimsCode
mkdir ~/.vim && mv * ~/.vim
cd ~/.vim && mv vimrc-conf ~/.vimrc && mv vimrc2-conf ~/.vimrc2
cd ~/.vim/bundle/ && git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim > /dev/null 2>&1
echo -e 'Mise à jour en cours : [#####---------------](25%)\r'
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/
printf 'Mise à jour en cours : [#####---------------](25%%)\r'
echo "Utilisez-vous bash ou zsh ?"
printf "Utilisez-vous bash ou zsh ? "
read -r term
if [ "$term" = "bash" ]; then
if ! cat ~/.bashrc | grep -q 'alias vimscode="/bin/vimscode.sh"'; then
if ! grep -q 'alias vimscode="/bin/vimscode.sh"' ~/.bashrc; then
echo 'alias vimscode="/bin/vimscode.sh"' >> ~/.bashrc
fi
else
if ! cat ~/.zshrc | grep -q 'alias vimscode="/bin/vimscode.sh"'; then
if ! grep -q 'alias vimscode="/bin/vimscode.sh"' ~/.zshrc; then
echo 'alias vimscode="/bin/vimscode.sh"' >> ~/.zshrc
fi
fi
echo -e 'Mise à jour en cours : [##########----------](50%)\r'
printf 'Mise à jour en cours : [##########----------](50%%)\r'
vim -u ~/.vimrc2 -c PluginInstall -c q -c q > /dev/null 2>&1
rm -rf ~/.vimrc2
echo -e 'Mise à jour en cours : [###############-----](75%)\r'
printf 'Mise à jour en cours : [###############-----](75%%)\r'
cd ../ && rm -rf Vimscode
echo -e 'Mise à jour fini : [####################](100%)\r'
echo -e "Mise à jour terminé."
cd ../ && rm -rf VimsCode
printf 'Mise à jour fini : [####################](100%%)\r\n'
printf "Mise à jour terminée.\n"
}
if [ "$1" = "-maj" ]; then
maj
elif [ "$1" = '-install' ] ; then
install
elif [ "$1" = '-a' ] || [ "$1" = '-arduino' ] ; then
vim -p $2 ~/.vim/help/En/help-arduino
elif [ "$1" = '-e' ] || [ "$1" = '-esp' ] ; then
vim -p $2 ~/.vim/help/En/help-esp32
elif [ "$1" = '-p' ] || [ "$1" = '-platform.io' ] ; then
vim -p $2 ~/.vim/help/En/help-platform.io
elif [ "$1" = '' ] || [ "$1" = '' ] ; then
cat ~/.vim/help/help-vimscode
else
echo "Commande invalide"
fi
# 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
;;
*)
echo "Commande invalide"