Created
January 3, 2020 03:07
-
-
Save cornfeedhobo/ed9fe264375330e0612bfb237224e515 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cite about-plugin | |
about-plugin 'Bash My AWS' | |
export BASH_MY_AWS="$HOME/.bash-my-aws" | |
__bma_load () | |
{ | |
force=$1 | |
if [[ -d "$BASH_MY_AWS" ]] ; then | |
if [[ -z $force ]] || [[ ":$PATH:" != *":$BASH_MY_AWS/bin:"* ]] ; then | |
pathmunge "$BASH_MY_AWS/bin" | |
source "$BASH_MY_AWS/aliases" | |
source "$BASH_MY_AWS/bash_completion.sh" | |
fi | |
fi | |
} | |
update-bash-my-aws () | |
{ | |
about 'Update bash-my-aws to the latest' | |
group 'bash-my-aws' | |
if [[ ! -d "$BASH_MY_AWS" ]] ; then | |
git clone https://github.com/bash-my-aws/bash-my-aws.git $BASH_MY_AWS | |
echo "bash-my-aws successfully installed." | |
else | |
cd $BASH_MY_AWS || return | |
git fetch &> /dev/null | |
declare status | |
status="$(git rev-list master..origin/master 2> /dev/null)" | |
if [[ -n "${status}" ]]; then | |
for i in $(git rev-list --merges --first-parent master..origin); do | |
num_of_lines=$(git log -1 --format=%B $i | awk 'NF' | wc -l) | |
if [ $num_of_lines -eq 1 ]; then | |
description="%s" | |
else | |
description="%b" | |
fi | |
git --no-pager log --format="%h: $description (%an)" -1 $i | |
done | |
echo "" | |
read -e -n 1 -p "Would you like to update to $(git log -1 --format=%h origin/master)? [Y/n] " RESP | |
case $RESP in | |
[yY]|"") | |
git pull --rebase &> /dev/null | |
if [[ $? -eq 0 ]]; then | |
echo "bash-my-aws successfully updated." | |
else | |
echo "Error updating bash-my-aws, please, check if your bash-my-aws installation folder (${BASH_MY_AWS}) is clean." | |
fi | |
;; | |
[nN]) | |
echo "Not upgrading…" | |
;; | |
*) | |
echo -e "\033[91mPlease choose y or n.\033[m" | |
;; | |
esac | |
else | |
echo "bash-my-aws is up to date, nothing to do!" | |
fi | |
fi | |
__bma_load | |
} | |
__bma_load |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment