diff --git a/README.md b/README.md index 8c4aca9..bc77cce 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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: @@ -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 \ No newline at end of file diff --git a/install.sh b/install.sh index d5c508e..37e555f 100755 --- a/install.sh +++ b/install.sh @@ -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 @@ -60,7 +64,7 @@ __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 @@ -68,12 +72,12 @@ __am-prompt-install() { 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 @@ -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' diff --git a/src/scripts/aws-install b/src/scripts/aws-install new file mode 100755 index 0000000..f3b896e --- /dev/null +++ b/src/scripts/aws-install @@ -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 diff --git a/src/scripts/dotnet-install b/src/scripts/dotnet-install index a6ea175..d687002 100755 --- a/src/scripts/dotnet-install +++ b/src/scripts/dotnet-install @@ -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 diff --git a/src/scripts/eval/set-brew-path b/src/scripts/eval/set-brew-path new file mode 100755 index 0000000..381ca71 --- /dev/null +++ b/src/scripts/eval/set-brew-path @@ -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 diff --git a/src/scripts/eval/set-gcloud-path b/src/scripts/eval/set-gcloud-path index 5f18e94..c4d49cd 100755 --- a/src/scripts/eval/set-gcloud-path +++ b/src/scripts/eval/set-gcloud-path @@ -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 } diff --git a/src/scripts/eval/set-prompt b/src/scripts/eval/set-prompt index 44fc3e4..d4fd559 100755 --- a/src/scripts/eval/set-prompt +++ b/src/scripts/eval/set-prompt @@ -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 diff --git a/src/scripts/eval/set-python-path b/src/scripts/eval/set-python-path new file mode 100755 index 0000000..35d1394 --- /dev/null +++ b/src/scripts/eval/set-python-path @@ -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 diff --git a/src/scripts/eval/source-os b/src/scripts/eval/source-os index 24dd76a..cd843cf 100755 --- a/src/scripts/eval/source-os +++ b/src/scripts/eval/source-os @@ -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" diff --git a/src/scripts/gcloud-install b/src/scripts/gcloud-install index ef59f7c..43e28ea 100755 --- a/src/scripts/gcloud-install +++ b/src/scripts/gcloud-install @@ -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 diff --git a/template/bash_profile b/template/bash_profile index b68d91d..5c05fd4 100644 --- a/template/bash_profile +++ b/template/bash_profile @@ -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 \ No newline at end of file +fi diff --git a/uname/install-Darwin.sh b/uname/install-Darwin.sh index 509dae7..6e3abe9 100644 --- a/uname/install-Darwin.sh +++ b/uname/install-Darwin.sh @@ -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' @@ -41,8 +37,8 @@ __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) @@ -50,12 +46,12 @@ __am-prompt-install-darwin() { __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 diff --git a/uname/install-centos.sh b/uname/install-centos.sh new file mode 100644 index 0000000..7bf64c4 --- /dev/null +++ b/uname/install-centos.sh @@ -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 diff --git a/uname/install-debian.sh b/uname/install-debian.sh index 3922cbf..66add1d 100644 --- a/uname/install-debian.sh +++ b/uname/install-debian.sh @@ -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 diff --git a/uname/install-fedora.sh b/uname/install-fedora.sh index f0056bf..2279bf8 100644 --- a/uname/install-fedora.sh +++ b/uname/install-fedora.sh @@ -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" diff --git a/uname/install-linux.sh b/uname/install-linux.sh new file mode 100644 index 0000000..bdefa68 --- /dev/null +++ b/uname/install-linux.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +__am-prompt-install-linux() { + local BREWS=(gcc git bash bash-completion) + + if ! type brew 1>/dev/null 2>&1; then + __am-prompt-success 'installing homebrew...' + sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)" + + source "$SCRIPT_DIR/src/scripts/eval/set-brew-path" + fi + + __am-prompt-success 'updating homebrew...' + brew update + + set +e + + for pkg in "${BREWS[@]}"; do + if brew list -1 | grep -q "^${pkg}\$"; then + __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 + fi + done + + set -e + + local BASH_SHELL=$HOMEBREW_PREFIX/bin/bash + + if ! grep "$$BASH_SHELL" /etc/shells 1>/dev/null 2>&1; then + __am-prompt-success 'adding updated bash to shells...' + sudo bash -c "echo $BASH_SHELL >> /etc/shells" + fi + + if [[ "$SHELL" != "/usr/local/bin/bash" ]]; then + __am-prompt-success 'setting updated bash to default shell for user...' + chsh -s $BASH_SHELL + fi + + 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 + nvm use --lts --delete-prefix +} + +__am-prompt-install-linux diff --git a/uname/install-linuxmint.sh b/uname/install-linuxmint.sh new file mode 100755 index 0000000..ecdae6b --- /dev/null +++ b/uname/install-linuxmint.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +__am-prompt-install-mint() { + local PACKAGES=(build-essential curl file git) + + __am-prompt-success "updating software repositories..." + sudo apt-get update + + for pkg in "${PACKAGES[@]}"; do + __am-prompt-success "installing $pkg..." + sudo apt-get install -y ${pkg} + done + + __am-prompt-success "removing unnecessary dependencies..." + sudo apt-get autoremove -y + + source "$SCRIPT_DIR/uname/install-linux.sh" +} + +__am-prompt-install-mint diff --git a/uname/install-ubuntu.sh b/uname/install-ubuntu.sh index 3922cbf..73986e6 100644 --- a/uname/install-ubuntu.sh +++ b/uname/install-ubuntu.sh @@ -1,30 +1,23 @@ -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-ubuntu() { + 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 "setting up git-core repository..." + sudo add-apt-repository ppa:git-core/ppa -y -for pkg in openssl git build-essential libssl-dev curl libunwind8 gettext; do - success "Installing $pkg..." - sudo apt-get install -y ${pkg} -done + __am-prompt-success "updating software repositories..." + sudo apt-get update -sudo apt-get autoremove -y 1>/dev/null + for pkg in "${PACKAGES[@]}"; do + __am-prompt-success "installing $pkg..." + sudo apt-get install -y ${pkg} + done -curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash + __am-prompt-success "removing unnecessary dependencies..." + sudo apt-get autoremove -y -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-ubuntu