Skip to content

Commit

Permalink
feat(aws-install): add install for aws toolchain
Browse files Browse the repository at this point in the history
* use homebrew on both macOS and Linux
* migrate linux installations to support homebrew
* add set-python-path to support aws toolchain
* update readme to include tested operating systems

NOTE:

This update was tested on:

* macOS Mojave
* ubuntu 18.04
* fedora 29
* centOS 7
* debian 9
* mint 19
  • Loading branch information
dmccaffery committed Jun 26, 2019
1 parent d3a9c60 commit 4989391
Show file tree
Hide file tree
Showing 18 changed files with 218 additions and 116 deletions.
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
# promptMastermind

> A spectacular (BaSH) prompt for *nix distributions. (Only tested on macOS currently)
> A spectacular (BaSH) prompt for macOS and *nix distributions
## Vitals

Info | Badges
--------------|--------------
--------------|-------------------------------------
License | [![License][license-image]][license]
Chat | [![Join Chat][gitter-image]][gitter-url]

### Supported Operating Systems

Name | Version
-------|------------------
macOS | Sierra or greater
ubuntu | 16.04 or greater
fedora | 29 or greater
debian | 9 or greater
centOS | 7 or greater
mint | 19 or greater

## Getting Started

### What is promptMastermind?
### What is promptMastermind

promptMastermind is a prompt for BaSH on *nix distributions that includes a ton of useful functionality, including:

Expand Down Expand Up @@ -40,7 +50,7 @@ curl -fsSL https://git.io/am-prompt | /usr/bin/env bash
(Optional) Open the included Monokai theme (currently only supported on macOS):

``` bash
themes
theme
```

Updating promptMastermind:
Expand All @@ -61,12 +71,9 @@ The backup folder is located at: ```$HOME/.am/prompt/backup/[date]```.

The ```$HOME/.bash_profile``` is also backed up to ```$HOME/.am/prompt/backup/[date]/.bash_profile```.

## Copright and License
## Copyright and License

© automotiveMastermind and contributors. Distributed under the MIT license. See [LICENSE][] for details.

[license-image]: https://img.shields.io/badge/license-MIT-blue.svg
[license]: LICENSE

[gitter-url]: //gitter.im/automotivemastermind/prompt
[gitter-image]:https://img.shields.io/badge/⊪%20gitter-join%20chat%20→-1dce73.svg
14 changes: 9 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash

set -eo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

CLR_SUCCESS="\033[1;32m" # BRIGHT GREEN
CLR_CLEAR="\033[0m" # DEFAULT COLOR

Expand Down Expand Up @@ -60,20 +64,20 @@ __am-prompt-install() {

if type brew 1>/dev/null 2>&1; then
local LOCAL_PREFIX=$(brew --prefix)
elif [ -d $LOCALAPPDATA/git ]; then
elif [ -d ${LOCALAPPDATA:-}/git ]; then
local LOCAL_PREFIX=$(echo "/$LOCALAPPDATA/git" | sed -e 's/\\/\//g' -e 's/://')
else
local LOCAL_PREFIX=/usr/local
fi

local BASH_COMPLETION="$LOCAL_PREFIX/etc/bash_completion.d"
local UNAME=$(uname)
local UNAME_INSTALL="./uname/install-$UNAME.sh"
local UNAME_INSTALL="$SCRIPT_DIR/uname/install-$UNAME.sh"

if [ -e /etc/os-release ]; then
if [ -f /etc/os-release ]; then
source /etc/os-release

local UNAME_INSTALL="./uname/install-$ID.sh"
local UNAME_INSTALL="$SCRIPT_DIR/uname/install-$ID.sh"
fi

if [ -f "$UNAME_INSTALL" ]; then
Expand All @@ -98,7 +102,7 @@ __am-prompt-install() {

if [ "$CURL_RESULT" = "200" ]; then
__am-prompt-success 'successfully installed git-prompt'
chmod +x "PROMPT_COMPLETION/$GIT_PROMPT_NAME" 1>/dev/null 2>&1
chmod +x "$PROMPT_COMPLETION/$GIT_PROMPT_NAME" 1>/dev/null
fi

local CURL_OPT='-s'
Expand Down
26 changes: 26 additions & 0 deletions src/scripts/aws-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

__am-prompt-aws-install() {
local BREWS=(awscli aws-sam-cli)

brew tap aws/tap
brew update

for pkg in "${BREWS[@]}"; do
if brew list -1 | grep -q "^${pkg}\$"; then
echo "upgrading: $pkg..."
brew upgrade $pkg 2>/dev/null
brew link --overwrite $pkg 2>/dev/null
else
echo "installing: $pkg..."
brew install $pkg
fi
done

echo
echo "configuring aws..."
echo
aws configure
}

__am-prompt-aws-install
4 changes: 2 additions & 2 deletions src/scripts/dotnet-install
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ __am-prompt-dotnet-install() {
mkdir -p /usr/local/share 1>/dev/null 2>&1
ln -s "$DOTNET_INSTALL_DIR" "/usr/local/share" 1>/dev/null 2>&1

if [ -e "/usr/local/share/dotnet" ]; then
if [ -f "/usr/local/share/dotnet/dotnet" ]; then
export PATH="/usr/local/share/dotnet:$PATH"
fi

if [ -e "$HOME/.dotnet/dotnet" ]; then
if [ -f "$HOME/.dotnet/dotnet" ]; then
export PATH="$HOME/.dotnet:$PATH"
fi

Expand Down
9 changes: 9 additions & 0 deletions src/scripts/eval/set-brew-path
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

if [ -f "$HOME/.linuxbrew/bin/brew" ]; then
eval $("$HOME/.linuxbrew/bin/brew" shellenv)
fi

if [ -f /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
fi
4 changes: 2 additions & 2 deletions src/scripts/eval/set-gcloud-path
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ __am-prompt-set-gcloud-path() {
local GCLOUD_PATH_INC="$HOME/.gcloud/path.bash.inc"
local GCLOUD_COMPLETION_INC="$HOME/.gcloud/completion.bash.inc"

if [ -e "$GCLOUD_PATH_INC" ]; then
if [ -f "$GCLOUD_PATH_INC" ]; then
source "$GCLOUD_PATH_INC"
fi

if [ -e "$GCLOUD_COMPLETION_INC" ]; then
if [ -f "$GCLOUD_COMPLETION_INC" ]; then
source "$GCLOUD_COMPLETION_INC"
fi
}
Expand Down
7 changes: 1 addition & 6 deletions src/scripts/eval/set-prompt
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,8 @@ __am-prompt-dotnet_bash_complete() {
__am-prompt-set-nvm() {
NVM_PATH=$(brew --prefix nvm 2>/dev/null)

if [ -z ${NVM_PATH+x} ]; then
NVM_PATH=$HOME/.nvm
fi

if [ ! -d ${NVM_PATH} ]; then
echo "not found"
return
NVM_PATH=$HOME/.nvm
fi

if [ -f "$NVM_PATH/nvm.sh" ]; then
Expand Down
8 changes: 8 additions & 0 deletions src/scripts/eval/set-python-path
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

PYTHON=$(command -v python3 2>/dev/null || command -v python 2>/dev/null)

if [ -f $PYTHON ]; then
USER_BASE_PATH=$($PYTHON -m site --user-base)
export PATH=$PATH:$USER_BASE_PATH/bin
fi
2 changes: 1 addition & 1 deletion src/scripts/eval/source-os
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ __am-prompt-source-os() {
local UNAME=$(uname)
local UNAME_PATH="$HOME/.am/prompt/scripts/$UNAME"

if [ -e /etc/os-release ]; then
if [ -f /etc/os-release ]; then
source /etc/os-release

local UNAME="$ID"
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/gcloud-install
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ __am-prompt-gcloud-install() {

local GCLOUD_PATH_INC="$HOME/.gcloud/path.bash.inc"

if [ -e "$GCLOUD_PATH_INC" ]; then
if [ -f "$GCLOUD_PATH_INC" ]; then
source "$GCLOUD_PATH_INC"
fi
fi
Expand Down
4 changes: 2 additions & 2 deletions template/bash_profile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash

if [ -e $HOME/.am/prompt/bashrc ]; then
if [ -f $HOME/.am/prompt/bashrc ]; then
source $HOME/.am/prompt/bashrc
fi
fi
42 changes: 19 additions & 23 deletions uname/install-Darwin.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
#!/usr/bin/env bash

CLR_SUCCESS="\033[1;32m" # BRIGHT GREEN
CLR_CLEAR="\033[0m" # DEFAULT COLOR

__am-prompt-install-darwin() {
local BREWS=(bash openssl git go nvm bash-completion python)

if ! type brew 1>/dev/null 2>&1; then
__am-prompt-success 'installing homebrew'
__am-prompt-success 'installing homebrew...'
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi

__am-prompt-success 'updating homebrew'
brew update 1>/dev/null
__am-prompt-success 'updating homebrew...'
brew update

for pkg in git-flow; do
if brew list -1 | grep -q "^${pkg}\$"; then
__am-prompt-success "uninstalling: $pkg"
brew uninstall $pkg 1>/dev/null 2>&1
fi
done
set +e

for pkg in bash openssl git go nvm bash-completion; do
for pkg in "${BREWS[@]}"; do
if brew list -1 | grep -q "^${pkg}\$"; then
__am-prompt-success "upgrading: $pkg"
brew upgrade $pkg 1>/dev/null 2>&1
brew link --overwrite $pkg 1>/dev/null 2>&1
__am-prompt-success "upgrading: $pkg..."
brew upgrade $pkg 2>/dev/null
brew link --overwrite $pkg 2>/dev/null
else
__am-prompt-success "installing: $pkg"
brew install $pkg 1>/dev/null 2>&1
__am-prompt-success "installing: $pkg..."
brew install $pkg
fi
done

set -e

if ! grep "/usr/local/bin/bash" /etc/shells 1>/dev/null 2>&1; then
__am-prompt-success 'adding updated bash to shells...'
sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells'
Expand All @@ -41,21 +37,21 @@ __am-prompt-install-darwin() {
fi

mkdir -p /usr/local/lib 1>/dev/null 2>&1
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/ 1>/dev/null 2>&1
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/ 1>/dev/null 2>&1
ln -sf /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/ 1>/dev/null 2>&1
ln -sf /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/ 1>/dev/null 2>&1

local NVM_PATH=$(brew --prefix nvm)

if [ -f "$NVM_PATH/nvm.sh" ]; then
__am-prompt-success 'setting up nvm...'
export NVM_DIR="${HOME}/.nvm"
source "$NVM_PATH/nvm.sh"
nvm install --lts 1>/dev/null 2>&1
nvm use --lts --delete-prefix --silent 1>/dev/null 2>&1
nvm install --lts 2>/dev/null
nvm use --lts --delete-prefix --silent 2>/dev/null
fi

__am-prompt-success 'setting git credential helper to use the macOS keychain'
git config --system credential.helper osxkeychain 1>/dev/null
git config --system credential.helper osxkeychain
}

__am-prompt-install-darwin
18 changes: 18 additions & 0 deletions uname/install-centos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

__am-prompt-install-centos() {
local YUM=$(command -v dnf 2>/dev/null || command -v yum)
local PACKAGES=(curl file git)

__am-prompt-success "installing development tools..."
sudo $YUM groupinstall -y "Development Tools"

for pkg in "${PACKAGES[@]}"; do
__am-prompt-success "installing $pkg..."
sudo $YUM install -y ${pkg}
done

source "$SCRIPT_DIR/uname/install-linux.sh"
}

__am-prompt-install-centos
38 changes: 14 additions & 24 deletions uname/install-debian.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
CLR_SUCCESS="\033[1;32m" # BRIGHT GREEN
CLR_CLEAR="\033[0m" # DEFAULT COLOR
#!/usr/bin/env bash

success() {
echo -e "${CLR_SUCCESS}$1${CLR_CLEAR}"
}

sudo add-apt-repository ppa:git-core/ppa -y 1>/dev/null 2>&1
sudo apt-get update 1>/dev/null
__am-prompt-install-debian() {
local PACKAGES=(build-essential curl file git)

for pkg in git-flow; do
if apt list $pkg | grep -q "&${pkg}(.*)\[installed\]$" 2>/dev/null; then
sudo apt-get remove -y $pkg 1>/dev/null
fi
done
__am-prompt-success "updating software repositories..."
sudo apt-get update

for pkg in openssl git build-essential libssl-dev curl libunwind8 gettext; do
success "Installing $pkg..."
sudo apt-get install -y ${pkg}
done
for pkg in "${PACKAGES[@]}"; do
__am-prompt-success "installing $pkg..."
sudo apt-get install -y ${pkg}
done

sudo apt-get autoremove -y 1>/dev/null
__am-prompt-success "removing unnecessary dependencies..."
sudo apt-get autoremove -y

curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

export NVM_DIR="$HOME/.nvm"
source "$NVM_DIR/nvm.sh"
source "$SCRIPT_DIR/uname/install-linux.sh"
}

nvm install --lts 1>/dev/null
nvm use --lts --delete-prefix 1>/dev/null
__am-prompt-install-debian
20 changes: 2 additions & 18 deletions uname/install-fedora.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
CLR_SUCCESS="\033[1;32m" # BRIGHT GREEN
CLR_CLEAR="\033[0m" # DEFAULT COLOR
#!/usr/bin/env bash

success() {
echo -e "${CLR_SUCCESS}$1${CLR_CLEAR}"
}

for pkg in openssl git libunwind libicu; do
success "Installing $pkg..."
sudo dnf install ${pkg}
done

curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

export NVM_DIR="$HOME/.nvm"
source "$NVM_DIR/nvm.sh"

nvm install --lts 1>/dev/null
nvm use --lts --delete-prefix 1>/dev/null
source "$SCRIPT_DIR/uname/install-centos.sh"
Loading

0 comments on commit 4989391

Please sign in to comment.