#!/bin/bash # COLORS source color.sh KEY_PHRASE="#hugogogo#" HERE=$(pwd) D_CONFIG_FILES="config_files" # create those folders if necessary : mkdir -p ~/.vim/templates mkdir -p ~/.vim/swapfiles # receive 1 argument : absolute path to config file function save_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 echo -en $YELLOW"in " echo -en $CYAN"\"$path_file_to/\"" echo -en $YELLOW", mv " echo -en $CYAN"\"$file_name\"" echo -en $YELLOW" to " echo -en $CYAN"\"$file_name.hubak$number\""$ENDCO"\n" mv $file_to $file_to.hubak$number } # receive 1 argument : absolute path to config file function install { file_to="$1" file_name="$(basename $1)" path_file_to="$(dirname $1)" if [ -f $file_to ] then save_bak $file_to fi echo -en $YELLOW"create symlink of " echo -en $CYAN"\"$file_name\"" echo -en $YELLOW" in " echo -en $CYAN"\"$path_file_to\""$ENDCO"\n" ln -s $HERE/$D_CONFIG_FILES/$file_name $file_to } # argument : directory where the config file should go install "$home/.screenrc" install "$home/.vimrc" install "$home/.zshrc" install "$home/.vim/templates/skeleton_color.h" install "$home/.vim/templates/skeleton.cpp" install "$home/.vim/templates/skeleton.hpp" install "$home/.vim/templates/skeleton_main.cpp" install "$home/.vim/templates/skeleton_makefile"