Files
huhuhu_config/uninstall.sh

63 lines
1.4 KiB
Bash

#!/bin/bash
# COLORS
source color.sh
KEY_PHRASE="#hugogogo#"
# receive 1 argument : absolute path to config file
function restore_bak
{
file_to="$1"
file_name="$(basename $1)"
path_file_to="$(dirname $1)"
number=0
while [ -f $file_to.hubak$number ]
do
((number+=1))
done
((number-=1))
echo -en $YELLOW"in "
echo -en $CYAN"\"$path_file_to/\""
echo -en $YELLOW", mv "
echo -en $CYAN"\"$file_name.hubak$number\""
echo -en $YELLOW" to "
echo -en $CYAN"\"$file_name\""$ENDCO"\n"
mv $file_to.hubak$number $file_to
}
# receive 1 argument : absolute path to config file
function uninstall
{
file_to="$1"
file_name="$(basename $1)"
path_file_to="$(dirname $1)"
# -L check if is symlink
if [ -f $file_to ] && [ -L $file_to ]
then
if grep -q $KEY_PHRASE $file
then
if [ -f $file_to.hubak0 ]
then
echo -en $YELLOW"in "
echo -en $CYAN"\"$path_file_to/\""
echo -en $YELLOW", rm symlink "
echo -en $CYAN"\"$file_name\""$ENDCO"\n"
rm $file_to
restore_bak $file_to
fi
fi
fi
}
# argument : directory where the config file should go
uninstall "$HOME/.screenrc"
uninstall "$HOME/.vimrc"
uninstall "$HOME/.zshrc"
uninstall "$home/.vim/templates/skeleton_color.h"
uninstall "$home/.vim/templates/skeleton.cpp"
uninstall "$home/.vim/templates/skeleton.hpp"
uninstall "$home/.vim/templates/skeleton_main.cpp"
uninstall "$home/.vim/templates/skeleton_makefile"