add --no-modify-config flag to install.sh

pull/810/head
Shingo Kitagawa 2016-11-04 17:42:40 +09:00
parent 7ffb9e2579
commit 00d17ff16a
1 changed files with 40 additions and 37 deletions

View File

@ -9,6 +9,7 @@ function show_usage() {
echo "--help (-h): Display this help message"
echo "--silent (-s): Install default settings without prompting for input";
echo "--interactive (-i): Interactively choose plugins"
echo "--no-modify-config (-n): Do not modify existing config file"
exit 0;
}
@ -67,17 +68,19 @@ for param in "$@"; do
"--help") set -- "$@" "-h" ;;
"--silent") set -- "$@" "-s" ;;
"--interactive") set -- "$@" "-i" ;;
"--no-modify-config") set -- "$@" "-n" ;;
*) set -- "$@" "$param"
esac
done
OPTIND=1
while getopts "hsi" opt
while getopts "hsin" opt
do
case "$opt" in
"h") show_usage; exit 0 ;;
"s") silent=true ;;
"i") interactive=true ;;
"n") no_modify_config=true ;;
"?") show_usage >&2; exit 1 ;;
esac
done
@ -101,6 +104,7 @@ esac
BACKUP_FILE=$CONFIG_FILE.bak
echo "Installing bash-it"
if ! [[ $silent ]] && ! [[ $no_modify_config ]]; then
if [ -e "$HOME/$BACKUP_FILE" ]; then
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2
while ! [ $silent ]; do
@ -141,8 +145,7 @@ while ! [ $silent ]; do
;;
esac
done
if [ $silent ]; then
elif [[ $silent ]] && ! [[ $no_modify_config ]]; then
# backup/new by default
backup_new
fi