diff --git a/lib/uninstall.bash b/lib/uninstall.bash index 03daa29..fcce83e 100644 --- a/lib/uninstall.bash +++ b/lib/uninstall.bash @@ -2,22 +2,32 @@ # Constants +BACKUP_SUFFIX='.ORIGINAL' + # Functions -function uninstall { - if [[ -f /etc/bash.bashrc.ORIGINAL ]]; then - sudo rm /etc/bash.bashrc - sudo mv /etc/bash.bashrc.ORIGINAL /etc/bash.bashrc +function restore { + local path="$1" + local backup="${path}${BACKUP_SUFFIX}" + if [[ -f "$backup" ]]; then + sudo rm "$path" + sudo mv "$backup" "$path" + echo "$path restored!" fi +} - if [[ -f /etc/inputrc.ORIGINAL ]]; then - sudo rm /etc/inputrc - sudo mv /etc/inputrc.ORIGINAL /etc/inputrc - fi +function uninstall { + restore /etc/bash.bashrc + restore /etc/inputrc + restore /etc/skel/.bashrc sudo rm /etc/profile.d/20-miaou-bash.sh sudo rm -f /etc/vimrc/vimrc.{azerty,core,local,miaou,rookie} + sudo rm -f /usr/bin/miaou-bash sudo rm -rf /opt/miaou-bash + + echo 'MIAOU-BASH fully uninstalled, previous settings have been restored from original' + echo -e "To reset your shell, please run:\n\texec bash -l" } # Main @@ -27,8 +37,6 @@ assert_system_mode sudo_root if _confirm_destructive 2>/dev/null; then uninstall - echo 'MIAOU-BASH fully uninstalled, previous settings have been restored from original' - echo "to reset your shell, please run: \`exec bash -l\`" else builtin exit 1 fi