commit
bf7ff19abc
79
install.sh
79
install.sh
|
|
@ -13,52 +13,51 @@ esac
|
||||||
BACKUP_FILE=$CONFIG_FILE.bak
|
BACKUP_FILE=$CONFIG_FILE.bak
|
||||||
|
|
||||||
if [ -e "$HOME/$BACKUP_FILE" ]; 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
|
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
|
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
|
||||||
case $RESP in
|
case $RESP in
|
||||||
[yY])
|
[yY])
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
[nN]|"")
|
[nN]|"")
|
||||||
echo -e "\033[91mInstallation aborted. Please come back soon!\033[m"
|
echo -e "\033[91mInstallation aborted. Please come back soon!\033[m"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "\033[91mPlease choose y or n.\033[m"
|
echo -e "\033[91mPlease choose y or n.\033[m"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
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
|
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
|
case $choice in
|
||||||
[yY])
|
[yY])
|
||||||
test -w "$HOME/$CONFIG_FILE" &&
|
test -w "$HOME/$CONFIG_FILE" &&
|
||||||
cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
|
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"
|
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"
|
(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"
|
echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
[nN]|"")
|
[nN]|"")
|
||||||
test -w "$HOME/$CONFIG_FILE" &&
|
test -w "$HOME/$CONFIG_FILE" &&
|
||||||
cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
|
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"
|
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"
|
sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "\033[91mPlease choose y or n.\033[m"
|
echo -e "\033[91mPlease choose y or n.\033[m"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m"
|
echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m"
|
||||||
|
|
||||||
function load_one() {
|
function load_one() {
|
||||||
|
|
@ -68,9 +67,9 @@ function load_one() {
|
||||||
|
|
||||||
dest="${BASH_IT}/${file_type}/enabled/${file_to_enable}"
|
dest="${BASH_IT}/${file_type}/enabled/${file_to_enable}"
|
||||||
if [ ! -e "${dest}" ]; then
|
if [ ! -e "${dest}" ]; then
|
||||||
ln -sf "../available/${file_to_enable}" "${dest}"
|
ln -sf "../available/${file_to_enable}" "${dest}"
|
||||||
else
|
else
|
||||||
echo "File ${dest} exists, skipping"
|
echo "File ${dest} exists, skipping"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue