From a3efe1479a52d593b8f5a99b767ab32977752883 Mon Sep 17 00:00:00 2001 From: Daniele Andreoli Date: Wed, 6 Jan 2016 12:53:05 +0100 Subject: [PATCH 1/4] Add follow sym link and option to append template to existing .bashrc --- install.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index b9926110..6e4232fd 100755 --- a/install.sh +++ b/install.sh @@ -32,11 +32,22 @@ if [ -e "$HOME/$BACKUP_FILE" ]; then done fi -test -w "$HOME/$CONFIG_FILE" && - cp -a "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && - echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" - -sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" +read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash_it templates at the end?[y/N] " choice + case $choice in + [yY]) + (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" || tail -n +2) >> "$HOME/$CONFIG_FILE" + echo -e "\033[0;32mBash_it template has correctly added to your $CONFIG_FILE\033[0m" + ;; + [nN]|"") + test -w "$HOME/$CONFIG_FILE" && + cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && + echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" + sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" + ;; + *) + echo -e "\033[91mPlease choose y or n.\033[m" + ;; + esac echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" From 55245cc98e816c63a91e92ccb298c7437e6f0e99 Mon Sep 17 00:00:00 2001 From: Daniele Andreoli Date: Thu, 7 Jan 2016 09:20:23 +0100 Subject: [PATCH 2/4] Fix typo and missing spaces --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 6e4232fd..f8afeaf7 100755 --- a/install.sh +++ b/install.sh @@ -32,11 +32,11 @@ if [ -e "$HOME/$BACKUP_FILE" ]; then done fi -read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash_it templates at the end?[y/N] " choice +read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice case $choice in [yY]) (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" || tail -n +2) >> "$HOME/$CONFIG_FILE" - echo -e "\033[0;32mBash_it template has correctly added to your $CONFIG_FILE\033[0m" + echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" ;; [nN]|"") test -w "$HOME/$CONFIG_FILE" && From fdc75e42b90bbacf46f8650a85569dee33e6d410 Mon Sep 17 00:00:00 2001 From: Daniele Andreoli Date: Thu, 7 Jan 2016 09:23:36 +0100 Subject: [PATCH 3/4] Add while block to allow correct choice --- install.sh | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/install.sh b/install.sh index f8afeaf7..678197df 100755 --- a/install.sh +++ b/install.sh @@ -32,22 +32,28 @@ if [ -e "$HOME/$BACKUP_FILE" ]; then done fi -read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice - case $choice in - [yY]) - (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" || tail -n +2) >> "$HOME/$CONFIG_FILE" - echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" - ;; - [nN]|"") - test -w "$HOME/$CONFIG_FILE" && - cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && - echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" - sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" - ;; - *) - echo -e "\033[91mPlease choose y or n.\033[m" - ;; - esac +while true +do + read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice + case $choice in + [yY]) + (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" || tail -n +2) >> "$HOME/$CONFIG_FILE" + echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" + break + ;; + [nN]|"") + test -w "$HOME/$CONFIG_FILE" && + cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && + echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" + sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" + break + ;; + *) + echo -e "\033[91mPlease choose y or n.\033[m" + ;; + esac +done + echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" From 245fcfa49b7aa1ff92e1216ecef231d743467eb6 Mon Sep 17 00:00:00 2001 From: Daniele Andreoli Date: Fri, 8 Jan 2016 02:20:18 +0100 Subject: [PATCH 4/4] Fix wrong pipe. Add in any case a backup file for compatibility --- install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 678197df..0009139f 100755 --- a/install.sh +++ b/install.sh @@ -37,7 +37,11 @@ do read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice case $choice in [yY]) - (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" || tail -n +2) >> "$HOME/$CONFIG_FILE" + test -w "$HOME/$CONFIG_FILE" && + cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && + echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" + + (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE" echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" break ;;