diff --git a/.circleci/config.yml b/.circleci/config.yml index 5812c4a..01ac32b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,22 +1,17 @@ version: 2 + jobs: macos: macos: - xcode: "10.2.1" + xcode: "11.2.1" steps: - checkout - run: - name: analyze - command: | - curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | bash - fossa init - fossa analyze - - run: - name: install - command: ./install.sh | tee log.txt + name: install-bash + command: ./install.sh bash | tee log.txt && bash -lc "git sha" - run: - name: verify - command: bash -l -c "git sha" + name: install-zsh + command: ./install.sh zsh | tee -a log.txt && zsh -lc "git sha" - store_artifacts: path: log.txt destination: logs/$CIRCLE_STAGE.txt @@ -73,6 +68,19 @@ jobs: path: log.txt destination: logs/$CIRCLE_STAGE.txt + fedora-31: + docker: + - image: docker:stable + steps: + - setup_remote_docker + - checkout + - run: + name: install and verify + command: docker build --file docker/$CIRCLE_STAGE/Dockerfile . | tee log.txt + - store_artifacts: + path: log.txt + destination: logs/$CIRCLE_STAGE.txt + centos: docker: - image: docker:stable @@ -112,21 +120,14 @@ jobs: keys: - yarn-packages-{{ checksum "yarn.lock" }} - run: - name: configure - command: | - git config user.email $GIT_AUTHOR_EMAIL - git config user.name $GIT_AUTHOR_NAME - - run: - name: install - command: yarn install --frozen-lockfile + name: publish + command: ./publish.sh - save_cache: name: save yarn package cache key: yarn-packages-{{ checksum "yarn.lock" }} paths: - ~/.cache/yarn - - run: - name: release - command: yarn run release + workflows: version: 2 install: @@ -151,6 +152,10 @@ workflows: filters: branches: ignore: master + - fedora-31: + filters: + branches: + ignore: master - centos: filters: branches: diff --git a/.dockerignore b/.dockerignore index 353f270..17bce9f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,10 @@ artifacts/ node_modules/ +docker/ + +*.md +*.lock +*.json +CODEOWNERS +LICENSE diff --git a/.fossa.yml b/.fossa.yml index dedf1eb..8b07213 100755 --- a/.fossa.yml +++ b/.fossa.yml @@ -1,11 +1,8 @@ -# Generated by FOSSA CLI (https://github.com/fossas/fossa-cli) -# Visit https://fossa.com to learn more - version: 2 cli: server: https://app.fossa.com fetcher: custom - project: https://github.com/dmccaffery/prompt + project: promptMastermind analyze: modules: - name: . diff --git a/.vscode/settings.json b/.vscode/settings.json index 72284fa..ba8144d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,5 +11,17 @@ }, "editor.trimAutoWhitespace": true, "editor.formatOnSave": true, - "files.trimTrailingWhitespace": true + "files.trimTrailingWhitespace": true, + "cSpell.words": [ + "dnvm", + "gcloud", + "keychain", + "macos", + "minikube", + "repos", + "symlink", + "toolchain", + "xcode", + "xplat" + ] } \ No newline at end of file diff --git a/README.md b/README.md index fdf7ecf..cc0a92b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # promptMastermind -> A spectacular (BaSH) prompt for macOS and *nix distributions +> A spectacular shell prompt for macOS and *nix distributions ![Preview][preview-image] @@ -25,12 +25,13 @@ mint | 19 or greater ## Know It -promptMastermind is a prompt for BaSH on *nix distributions that includes a ton of useful functionality, including: +promptMastermind is a prompt for sh, bash, and zsh on *nix distributions that includes a ton of useful functionality, +including: * A two-line prompt that displays username, hostname, and current path * Git prompt support (that emits information about the current branch and status when in a git path) -* Better BaSH completion for git and git-flow -* Installation of dotnet-cli +* Better tab completion for git and git-flow +* Installation of dotnet sdk, aws sdk, and gcloud sdk * Bookmarking support (cdable variables) * Variables support (add vars without modifying profile) * Flush DNS (on macOS) @@ -38,44 +39,73 @@ promptMastermind is a prompt for BaSH on *nix distributions that includes a ton * Display of available colors (already set as variables for use elsewhere) * ... and much more! -Note: All "extensions" are implemented as sourced function calls, so it should not interfere with existing +Note: All "extensions" are implemented as scripts added to the path, so it should not interfere with existing customization (aside from the prompt). ### Use It -Install promptMastermind in one step: +Install promptMastermind in one step (choose one of the following options): -``` bash -curl -fsSL https://git.io/am-prompt | /usr/bin/env bash +``` sh +# install and use bash +curl -fsSL https://git.io/am-prompt | sh -s -- bash + +# install and use zsh +curl -fsSL https://git.io/am-prompt | sh -s -- zsh +``` + +> NOTE: if you do not specify a shell, bash will be used by default + +#### Specific Versions + +Although it is **NOT** recommended, you can install a specific version of prompt using one of the following: + +``` sh +# install and use bash with prompt v6.0.0 +curl -fsSL https://git.io/am-prompt | sh -s -- --version v7.0.0 bash + +# install and use zsh with prompt v7.0.0 +curl -fsSL https://git.io/am-prompt | sh -s -- --version v7.0.0 zsh ``` -(Optional) Open the included Monokai theme (currently only supported on macOS): +All available versions of prompt are available here: https://github.com/automotiveMastermind/prompt/releases -``` bash -theme +> NOTE: zsh is only available as of v7.0.0 -- older versions of prompt only support bash + +(Optional) Open an included theme (currently only supported on macOS): + +``` sh +theme monokai # general high quality theme that has been around for many years +``` + +OR + +```sh +theme dark-mode # our own custom theme that is nice and bright for dark mode on macOS ``` Updating promptMastermind: -``` bash +``` sh update-prompt ``` -If you already have the latest version of prompt installed, the ```update-prompt``` command will not re-install the +If you already have the latest version of prompt installed, the `update-prompt` command will not re-install the current version. **NOTE**: The installer simply creates a new folder (.am) under the home folder and copies all of the files there. It will backup this folder first. It wires up the "extensions" by adding a source command for -```$HOME/.am/prompt/bashrc``` to ```$HOME/.bash_profile```. It will not duplicate itself, so you can re-run the -installer or use the ```upgrade-prompt``` command to upgrade at any time. +`$HOME/.am/prompt/bashrc` to `$HOME/.bash_profile`. It will not duplicate itself, so you can re-run the +installer or use the `upgrade-prompt` command to upgrade at any time. -The backup folder is located at: ```$HOME/.am/prompt/backup/[date]```. +The backup folder is located at: `$HOME/.am/backup/prompt/[date]`. -The ```$HOME/.bash_profile``` is also backed up to ```$HOME/.am/prompt/backup/[date]/.bash_profile```. +All profile and rc scripts such as `$HOME/.bash_profile` are also backed up to `$HOME/.am/backup/prompt/[date]/`. ## Build It -In order to test the installation routine for promptMastermind, we use a set of docker images for each of the supported *nix platforms. The build script in the `docker/` folder can be used to build all of the images, or specific ones: +In order to test the installation routine for promptMastermind, we use a set of docker images for each of the supported +*nix platforms. The build script in the `docker/` folder can be used to build all of the images, or specific ones: ```sh # build all of the platforms (this will take a while) @@ -88,7 +118,8 @@ In order to test the installation routine for promptMastermind, we use a set of ./docker/build.sh mint ``` -In addition, [circleci][circleci-uri] is used to build all platforms, including macOS as part of our pull request validation. Special thanks to [circleci][circleci-uri] for providing the build agents! +In addition, [circleci][circleci-uri] is used to build all platforms, including macOS as part of our pull request +validation. Special thanks to [circleci][circleci-uri] for providing the build agents! ## Copyright and License diff --git a/bootstrap.sh b/bootstrap.sh index ff4c207..ed2768a 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,33 +1,103 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-bootstrap() +set -e + +__am_prompt_update() { - local CURL_OPT='-s' - if [ ! -z "${GH_TOKEN:-}" ]; then - CURL_OPT='$CURL_OPT -H "Authorization: token $GH_TOKEN"' + local CLR_FAIL=${CLR_FAIL:-"\033[1;31m"} # BRIGHT RED + local CLR_SUCCESS=${CLR_SUCCESS:-"\033[1;32m"} # BRIGHT GREEN + local CLR_WARN=${CLR_WARN:-"\033[1;33m"} # BRIGHT YELLOW + local CLR_CLEAR=${CLR_CLEAR:-"\033[0m"} # DEFAULT COLOR + + local GH_TOKEN=${GH_TOKEN:-} + local PROMPT_TOKEN=${PROMPT_TOKEN:-} + local PROMPT_TOKEN=${PROMPT_TOKEN:-$GH_TOKEN} + local PROMPT_CURL_OPT=${PROMPT_CURL_OPT:-'-s'} + local PROMPT_COMMIT_REF=${PROMPT_COMMIT_REF:-"master"} + local PROMPT_SHELL=${PROMPT_SHELL:-"bash"} + local PROMPT_DRY_RUN=${PROMPT_DRY_RUN:-} + + while :; do + case $1 in + -t|--token) + PROMPT_TOKEN=$2 + shift + ;; + -v|--version) + PROMPT_COMMIT_REF=$2 + shift + ;; + -dr|--dry-run) + PROMPT_DRY_RUN=1 + ;; + -f|--force) + rm -rf "$HOME/.am/prompt/.sha" 1>/dev/null 2>&1 + ;; + --debug) + set -x + ;; + ?*) + PROMPT_SHELL=$1 + ;; + *) + break + ;; + esac + shift + done + + if [ ! -z "${PROMPT_TOKEN:-}" ]; then + PROMPT_CURL_OPT='$PROMPT_CURL_OPT -H "Authorization: token $PROMPT_TOKEN"' fi - local SHA_URI="https://api.github.com/repos/automotiveMastermind/prompt/commits/master" - local PROMPT_SHA=$(curl $CURL_OPT $SHA_URI | grep sha | head -n 1 | sed 's#.*\:.*"\(.*\).*",#\1#') - local SHA_PATH=$HOME/.am/prompt/$PROMPT_SHA + local PROMPT_SHA_URI="https://api.github.com/repos/automotiveMastermind/prompt/commits/$PROMPT_COMMIT_REF" + local PROMPT_SHA=$(curl $PROMPT_CURL_OPT $PROMPT_SHA_URI | grep sha | head -n 1 | sed 's#.*\:.*"\(.*\).*",#\1#') - if [ -f $SHA_PATH ]; then - echo "prompt: latest version already installed: $PROMPT_SHA" - exit 0 + # detect if sha could be located + if [ -z ${PROMPT_SHA:-} ]; then + echo "${CLR_FAIL}prompt: cannot retrieve SHA of latest version. Are you connected to the internet?${CLR_CLEAR}" + return 1 fi - local INSTALL_URI="https://github.com/automotiveMastermind/prompt/archive/master.tar.gz" - local INTALL_TEMP=$(mktemp -d) - local EXTRACT_TEMP="$INTALL_TEMP/extract" + local PROMPT_SHA_PATH=$HOME/.am/prompt/.sha - pushd $INTALL_TEMP 1>/dev/null - curl -skL $INSTALL_URI | tar zx + # detect if sha file exists + if [ -f "$PROMPT_SHA_PATH" ]; then + + # get the value of the sha file + PROMPT_CURRENT_SHA=$(cat "$PROMPT_SHA_PATH") + + # print latest version already installed + if [ "${PROMPT_SHA}" = "${PROMPT_CURRENT_SHA}" ]; then + echo "${CLR_SUCCESS}prompt: latest version already installed: ${PROMPT_SHA}.${CLR_CLEAR}" + echo " - run update-prompt with the --force flag to reinstall ${CLR_CLEAR}" + exit 0 + fi + fi + + if [ ! -z "${PROMPT_DRY_RUN:-}" ]; then + echo "${CLR_WARN}prompt: a new version of prompt is available: ${PROMPT_SHA}." + echo " - run the update-prompt command line tool to upgrade${CLR_CLEAR}" + return 0 + fi + + remove-backup + + local PROMPT_CHANGELOG_URI="https://github.com/automotivemastermind/prompt/blob/$PROMPT_COMMIT_REF/CHANGELOG.md" + local PROMPT_INSTALL_URI="https://github.com/automotiveMastermind/prompt/archive/$PROMPT_COMMIT_REF.tar.gz" + local PROMPT_INTALL_TEMP=$(mktemp -d) + local PROMPT_EXTRACT_TEMP="$PROMPT_INTALL_TEMP/extract" + + pushd $PROMPT_INTALL_TEMP 1>/dev/null + curl -skL $PROMPT_INSTALL_URI | tar zx pushd prompt-master 1>/dev/null - ./install.sh + ./install.sh $PROMPT_SHELL popd 1>/dev/null popd 1>/dev/null - rm -rf $INTALL_TEMP 1>/dev/null + rm -rf $PROMPT_INTALL_TEMP 1>/dev/null + + open-url $CHANGELOG_URI 1>/dev/null } -__am-prompt-bootstrap \ No newline at end of file +__am_prompt_update $@ diff --git a/docker/build.sh b/docker/build.sh index dbac890..c08e481 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -6,6 +6,9 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" REPO_DIR=$(dirname "$SCRIPT_DIR") LOGS_DIR="$REPO_DIR/artifacts/logs" +# enable buildkit by default +export DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1} + PLATFORMS=( "$@" ) if [ -z "${PLATFORMS:-}" ]; then @@ -18,5 +21,6 @@ for platform in "${PLATFORMS[@]}"; do dockerfile="$SCRIPT_DIR/$platform/Dockerfile" tag="prompt:$platform" - docker build --file "$dockerfile" --tag $tag "$REPO_DIR" | tee "$LOGS_DIR/$platform.log" + rm -f "$LOGS_DIR/$platform.log" 1>/dev/null 2>&1 || true + docker build --file "$dockerfile" --tag $tag "$REPO_DIR" | tee -a "$LOGS_DIR/$platform.log" done diff --git a/docker/centos/Dockerfile b/docker/centos/Dockerfile index c18d35e..22e78ee 100644 --- a/docker/centos/Dockerfile +++ b/docker/centos/Dockerfile @@ -1,19 +1,40 @@ FROM centos:7 -RUN yum install -y sudo \ - && yum clean all \ - && localedef -i en_US -f UTF-8 en_US.UTF-8 \ - && useradd -m -s /bin/bash am-prompt \ - && echo 'am-prompt ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers +RUN set -ex; \ + yum install -y sudo; \ + yum clean all; \ + localedef -i en_US -f UTF-8 en_US.UTF-8; \ + useradd -m -s /bin/bash am-prompt; \ + echo 'am-prompt ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers USER am-prompt WORKDIR /home/am-prompt ENV LANG=en_US.UTF-8 \ - USER=am-prompt + USER=am-prompt \ + AM_PROMPT_UPDATE=0 COPY . ./ -RUN ./install.sh -SHELL [ "/bin/bash", "-l" ] -RUN git-sha +# install bash +RUN set -ex; \ + ./install.sh bash + +# force the docker shell to bash +SHELL ["/home/linuxbrew/.linuxbrew/bin/bash", "-c"] + +# smoke test bash +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/bash"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/bash", "-lc", "git-sha"] + +# install zsh +RUN set -ex; \ + ./install.sh zsh + +# smoke test zsh +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/zsh"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/zsh", "-lc", "git-sha"] diff --git a/docker/debian/Dockerfile b/docker/debian/Dockerfile index 3b7e843..a29d96c 100644 --- a/docker/debian/Dockerfile +++ b/docker/debian/Dockerfile @@ -2,24 +2,45 @@ FROM debian:9 ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update \ - && apt-get install -y --no-install-recommends sudo locales uuid-runtime \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* \ - && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ - && dpkg-reconfigure locales \ - && update-locale LANG=en_US.UTF-8 \ - && useradd -m -s /bin/bash am-prompt \ - && echo 'am-prompt ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers +RUN set -ex; \ + apt-get update; \ + apt-get install -y --no-install-recommends sudo locales uuid-runtime; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen; \ + dpkg-reconfigure locales; \ + update-locale LANG=en_US.UTF-8; \ + useradd -m -s /bin/bash am-prompt; \ + echo 'am-prompt ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers USER am-prompt -WORKDIR /home/am-prompt/src +WORKDIR /home/am-prompt ENV LANG=en_US.UTF-8 \ - USER=am-prompt + USER=am-prompt \ + AM_PROMPT_UPDATE=0 COPY . ./ -RUN ./install.sh -SHELL [ "/bin/bash", "-l" ] -RUN git-sha +# install bash +RUN set -ex; \ + ./install.sh bash + +# force the docker shell to bash +SHELL ["/home/linuxbrew/.linuxbrew/bin/bash", "-c"] + +# smoke test bash +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/bash"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/bash", "-lc", "git-sha"] + +# install zsh +RUN set -ex; \ + ./install.sh zsh + +# smoke test zsh +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/zsh"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/zsh", "-lc", "git-sha"] diff --git a/docker/fedora-29/Dockerfile b/docker/fedora-29/Dockerfile index e7ce099..104c9d2 100644 --- a/docker/fedora-29/Dockerfile +++ b/docker/fedora-29/Dockerfile @@ -10,10 +10,30 @@ USER am-prompt WORKDIR /home/am-prompt ENV LANG=en_US.UTF-8 \ - USER=am-prompt + USER=am-prompt \ + AM_PROMPT_UPDATE=0 COPY . ./ -RUN ./install.sh -SHELL [ "/bin/bash", "-l" ] -RUN git-sha +# install bash +RUN set -ex; \ + ./install.sh bash + +# force the docker shell to bash +SHELL ["/home/linuxbrew/.linuxbrew/bin/bash", "-c"] + +# smoke test bash +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/bash"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/bash", "-lc", "git-sha"] + +# install zsh +RUN set -ex; \ + ./install.sh zsh + +# smoke test zsh +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/zsh"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/zsh", "-lc", "git-sha"] diff --git a/docker/fedora-30/Dockerfile b/docker/fedora-30/Dockerfile index 9df46b4..02ca6e4 100644 --- a/docker/fedora-30/Dockerfile +++ b/docker/fedora-30/Dockerfile @@ -10,10 +10,34 @@ USER am-prompt WORKDIR /home/am-prompt ENV LANG=en_US.UTF-8 \ - USER=am-prompt + USER=am-prompt \ + AM_PROMPT_UPDATE=0 COPY . ./ -RUN ./install.sh -SHELL [ "/bin/bash", "-l" ] -RUN git-sha +# install bash +RUN set -ex; \ + ./install.sh bash + +# install bash +RUN set -ex; \ + ./install.sh bash + +# force the docker shell to bash +SHELL ["/home/linuxbrew/.linuxbrew/bin/bash", "-c"] + +# smoke test bash +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/bash"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/bash", "-lc", "git-sha"] + +# install zsh +RUN set -ex; \ + ./install.sh zsh + +# smoke test zsh +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/zsh"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/zsh", "-lc", "git-sha"] diff --git a/docker/fedora-31/Dockerfile b/docker/fedora-31/Dockerfile new file mode 100644 index 0000000..3950d93 --- /dev/null +++ b/docker/fedora-31/Dockerfile @@ -0,0 +1,39 @@ +FROM fedora:31 + +RUN dnf install -y glibc-locale-source sudo util-linux-user libxcrypt-compat \ + && dnf clean all \ + && localedef -i en_US -f UTF-8 en_US.UTF-8 \ + && useradd -m -s /bin/bash am-prompt \ + && echo 'am-prompt ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers + +USER am-prompt +WORKDIR /home/am-prompt + +ENV LANG=en_US.UTF-8 \ + USER=am-prompt \ + AM_PROMPT_UPDATE=0 + +COPY . ./ + +# install bash +RUN set -ex; \ + ./install.sh bash + +# force the docker shell to bash +SHELL ["/home/linuxbrew/.linuxbrew/bin/bash", "-c"] + +# smoke test bash +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/bash"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/bash", "-lc", "git-sha"] + +# install zsh +RUN set -ex; \ + ./install.sh zsh + +# smoke test zsh +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/zsh"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/zsh", "-lc", "git-sha"] diff --git a/docker/mint/Dockerfile b/docker/mint/Dockerfile index 6d6de2e..ed1428b 100644 --- a/docker/mint/Dockerfile +++ b/docker/mint/Dockerfile @@ -14,10 +14,30 @@ USER am-prompt WORKDIR /home/am-prompt ENV LANG=en_US.UTF-8 \ - USER=am-prompt + USER=am-prompt \ + AM_PROMPT_UPDATE=0 COPY . ./ -RUN ./install.sh -SHELL [ "/bin/bash", "-l" ] -RUN git-sha +# install bash +RUN set -ex; \ + ./install.sh bash + +# force the docker shell to bash +SHELL ["/home/linuxbrew/.linuxbrew/bin/bash", "-c"] + +# smoke test bash +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/bash"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/bash", "-lc", "git-sha"] + +# install zsh +RUN set -ex; \ + ./install.sh zsh + +# smoke test zsh +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/zsh"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/zsh", "-lc", "git-sha"] diff --git a/docker/ubuntu/Dockerfile b/docker/ubuntu/Dockerfile index 7fa2632..5bb591b 100644 --- a/docker/ubuntu/Dockerfile +++ b/docker/ubuntu/Dockerfile @@ -2,22 +2,43 @@ FROM ubuntu:18.04 ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update \ - && apt-get install -y --no-install-recommends sudo locales uuid-runtime \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* \ - && localedef -i en_US -f UTF-8 en_US.UTF-8 \ - && useradd -m -s /bin/bash am-prompt \ - && echo 'am-prompt ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers +RUN set -ex; \ + apt-get update; \ + apt-get install -y --no-install-recommends sudo locales uuid-runtime; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + localedef -i en_US -f UTF-8 en_US.UTF-8; \ + useradd -m -s /bin/bash am-prompt; \ + echo 'am-prompt ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers USER am-prompt WORKDIR /home/am-prompt ENV LANG=en_US.UTF-8 \ - USER=am-prompt + USER=am-prompt \ + AM_PROMPT_UPDATE=0 COPY . ./ -RUN ./install.sh -SHELL [ "/bin/bash", "-l" ] -RUN git-sha +# install bash +RUN set -ex; \ + ./install.sh bash + +# force the docker shell to bash +SHELL ["/home/linuxbrew/.linuxbrew/bin/bash", "-c"] + +# smoke test bash +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/bash"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/bash", "-lc", "git-sha"] + +# install zsh +RUN set -ex; \ + ./install.sh zsh + +# smoke test zsh +RUN echo "$SHELL" | grep "/home/linuxbrew/.linuxbrew/bin/zsh"; + +# smoke test prompt +RUN ["/home/linuxbrew/.linuxbrew/bin/zsh", "-lc", "git-sha"] diff --git a/install.sh b/install.sh index 35570a6..6dc692b 100755 --- a/install.sh +++ b/install.sh @@ -1,31 +1,30 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -set -eo pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +set -e CLR_SUCCESS="\033[1;32m" # BRIGHT GREEN CLR_CLEAR="\033[0m" # DEFAULT COLOR +ECHO='echo' + +AM_HOME="$HOME/.am" +AM_PROMPT="$AM_HOME/prompt" # when not outputing to a tty, add spacing instead of colors if [ ! -t 1 ]; then - CLR_SUCCESS="\n------------------------------------------------------------------------------------------------------------------------ -\n" + CLR_SUCCESS="\n------------------------------------------------------------------------------------------------------------------------\n" CLR_CLEAR=$CLR_SUCCESS + ECHO='printf' fi -__am-prompt-success() { - echo -e "${CLR_SUCCESS}prompt-install: $1${CLR_CLEAR}" +__am_prompt_success() { + $ECHO "${CLR_SUCCESS}prompt-install: $1${CLR_CLEAR}" } -__am-prompt-install() { - local AM_HOME="$HOME/.am" - local AM_PROMPT="$AM_HOME/prompt" - +__am_prompt_install() { local NOW=$(date +"%Y%m%d_%H%M%S") local BACKUP_PATH="$AM_HOME/backup/prompt/$NOW" - __am-prompt-success "creating backup path: $BACKUP_PATH" + __am_prompt_success "creating backup path: $BACKUP_PATH" mkdir -p "$BACKUP_PATH" 1>/dev/null for TEMPLATE in template/*; do @@ -33,83 +32,81 @@ __am-prompt-install() { local TEMPLATE_PATH="$HOME/.${TEMPLATE_NAME}" if [ -f "$TEMPLATE_PATH" ]; then - __am-prompt-success "backing up ${TEMPLATE_NAME}" + __am_prompt_success "backing up ${TEMPLATE_NAME}" cp "$TEMPLATE_PATH" "$BACKUP_PATH/$TEMPLATE_NAME" fi - cat "$TEMPLATE" > "$TEMPLATE_PATH" + cp "$TEMPLATE" "$TEMPLATE_PATH" done if [ -d $AM_PROMPT ]; then - __am-prompt-success "backing up $AM_PROMPT" + __am_prompt_success "backing up $AM_PROMPT" cp -R $AM_PROMPT/* "$BACKUP_PATH" 1>/dev/null - __am-prompt-success "removing $AM_PROMPT" - rm -rf "$AM_PROMPT/git" 1>/dev/null 2>&1 - rm -rf "$AM_PROMPT/scripts" 1>/dev/null 2>&1 + __am_prompt_success "removing $AM_PROMPT" + rm -rf "$AM_PROMPT/bash" 1>/dev/null 2>&1 + rm -rf "$AM_PROMPT/sh" 1>/dev/null 2>&1 + rm -rf "$AM_PROMPT/zsh" 1>/dev/null 2>&1 rm -rf "$AM_PROMPT/themes" 1>/dev/null 2>&1 + + # remove legacy paths + rm -rf "$AM_PROMPT/completions" 1>/dev/null 2>&1 + rm -rf "$AM_PROMPT/scripts" 1>/dev/null 2>&1 rm -f "$AM_PROMPT/bashrc" 1>/dev/null 2>&1 fi - __am-prompt-success "creating $AM_PROMPT" + __am_prompt_success "creating $AM_PROMPT" mkdir -p "$AM_PROMPT/user" 1>/dev/null 2>&1 - __am-prompt-success "installing promptMastermind to $AM_PROMPT" - cp -Rf src/scripts "$AM_PROMPT" 1>/dev/null + __am_prompt_success "installing promptMastermind to $AM_PROMPT" + cp -Rf src/bash "$AM_PROMPT" 1>/dev/null + cp -Rf src/sh "$AM_PROMPT" 1>/dev/null + cp -Rf src/zsh "$AM_PROMPT" 1>/dev/null cp -Rf src/themes "$AM_PROMPT" 1>/dev/null - cp -f src/bashrc "$AM_PROMPT" 1>/dev/null for USER_ITEM in src/user/*; do local USER_ITEM_NAME=$(basename "$USER_ITEM") local USER_ITEM_PATH="$AM_PROMPT/user/$USER_ITEM_NAME" if [ ! -f "$USER_ITEM_PATH" ]; then - __am-prompt-success "initializing user profile: $USER_ITEM_NAME at $USER_ITEM_PATH" + __am_prompt_success "initializing user profile: $USER_ITEM_NAME at $USER_ITEM_PATH" cp "$USER_ITEM" "$USER_ITEM_PATH" fi done - if type brew 1>/dev/null 2>&1; then - local LOCAL_PREFIX=$(brew --prefix) - 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 | tr [:upper:] [:lower:]) - local UNAME_INSTALL="$SCRIPT_DIR/uname/install-$UNAME.sh" + local UNAME=$(uname | tr '[:upper:]' '[:lower:]') + local UNAME_INSTALL="$UNAME.sh" if [ -f /etc/os-release ]; then - source /etc/os-release + . /etc/os-release - local UNAME_INSTALL="$SCRIPT_DIR/uname/install-$ID.sh" + local UNAME_INSTALL="$ID.sh" fi - if [ -f "$UNAME_INSTALL" ]; then - source "$UNAME_INSTALL" + if [ -f "$AM_PROMPT/sh/install/$UNAME_INSTALL" ]; then + . "$AM_PROMPT/sh/install/$UNAME_INSTALL" fi - local GIT_PROMPT_NAME=git-prompt.sh - local GIT_PROMPT_URI=https://raw.githubusercontent.com/lyze/posh-git-sh/master/$GIT_PROMPT_NAME - local PROMPT_COMPLETION="$AM_PROMPT/completions" - - if [ -f "$BASH_COMPLETION/$GIT_PROMPT_NAME" ]; then - __am-prompt-success 'removing crappy git-prompt' - rm -rf "$BASH_COMPLETION/$GIT_PROMPT_NAME" 1>/dev/null + if [ ! -d "$AM_PROMPT/zsh/completions" ]; then + mkdir -p "$AM_PROMPT/zsh/completions" 1>/dev/null fi - if [ ! -d "$PROMPT_COMPLETION" ]; then - mkdir -p "$PROMPT_COMPLETION" 1>/dev/null + if [ ! -d "$AM_PROMPT/bash/completions" ]; then + mkdir -p "$AM_PROMPT/bash/completions" 1>/dev/null fi - __am-prompt-success 'downloading better git-prompt' - local CURL_RESULT=$(curl -sLD- "$GIT_PROMPT_URI" -o "$PROMPT_COMPLETION/$GIT_PROMPT_NAME" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/") + local GIT_PROMPT_NAME=git-prompt.sh + local GIT_PROMPT_URI=https://raw.githubusercontent.com/lyze/posh-git-sh/master/$GIT_PROMPT_NAME + + __am_prompt_success 'downloading better git-prompt' + local CURL_RESULT=$(curl -sLD- "$GIT_PROMPT_URI" -o "$AM_PROMPT/zsh/completions/_git-prompt" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/") if [ "$CURL_RESULT" = "200" ]; then - __am-prompt-success 'successfully installed git-prompt' - chmod +x "$PROMPT_COMPLETION/$GIT_PROMPT_NAME" 1>/dev/null + __am_prompt_success 'successfully installed git-prompt' + chmod +x "$AM_PROMPT/zsh/completions/_git-prompt" 1>/dev/null + + # copy for consumption in bash as well + cp "$AM_PROMPT/zsh/completions/_git-prompt" "$AM_PROMPT/bash/completions/git-prompt.sh" fi local CURL_OPT='-s' @@ -124,13 +121,11 @@ __am-prompt-install() { echo $PROMPT_SHA > $PROMPT_SHA_PATH - echo -e "${CLR_SUCCESS}" - echo "#######################################" - echo "#######################################" - echo " PLEASE RUN: exec -l \$SHELL" - echo "#######################################" - echo "#######################################" - echo -e "${CLR_CLEAR}" + local PROMPT_SHELL="${1:-"bash"}" + local PROMPT_SHELL=$(echo $PROMPT_SHELL | tr '[:upper:]' '[:lower:]') + + # use the correct shell + . $AM_PROMPT/sh/scripts/use-shell $PROMPT_SHELL } -__am-prompt-install +__am_prompt_install $@ diff --git a/package.json b/package.json index bf03fd6..9db94dc 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "url": "https://github.com/automotivemastermind/prompt/issues" }, "homepage": "https://github.com/automotivemastermind/prompt#readme", - "devDependencies": { + "dependencies": { "lodash.template": "^4.5.0", "standard-version": "^6.0.1" } diff --git a/publish.sh b/publish.sh new file mode 100644 index 0000000..62d196e --- /dev/null +++ b/publish.sh @@ -0,0 +1,39 @@ +#! /usr/bin/env sh + +set -eu + +# set the git author and email +GIT_AUTHOR_EMAIL=${GIT_AUTHOR_EMAIL:-"open@automotivemastermind.com"} +GIT_AUTHOR_NAME=${GIT_AUTHOR_NAME:="aM Open Source"} + +git config --set user.name $GIT_AUTHOR_NAME +git config --set user.email $GIT_AUTHOR_NAME + +# install yarn assets +yarn install --frozen-lockfile + +# detect fossa api key +if [ ! -z "${FOSSA_API_KEY:-}" ]; then + + # determine if fossa is available + if ! test type fossa 1>/dev/null 2>&1; then + + # get fossa + curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | bash + fi + + # run fossa analyze + fossa analyze + + # wait for fossa report + fossa test + + # generate license file + fossa report licenses > NOTICE.md + + # add the notice to the current commit + git add --force NOTICE.md +fi + +# create the release +yarn run release diff --git a/src/bash/bashrc b/src/bash/bashrc new file mode 100755 index 0000000..2bf30eb --- /dev/null +++ b/src/bash/bashrc @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +# shell options +shopt -s checkwinsize # check window size on script exit +shopt -s cdable_vars # enable change directory to a variable value +shopt -s extglob # enable extended glob patterns +shopt -s globstar # enable glob ** expansion + +# get bash completion dir +export BASH_COMPLETION_DIR="$LOCAL_PREFIX/etc/bash_completion.d" + +# system binds for bash completion (for interactive terminals) +if [ -t 1 ]; then + bind "set completion-ignore-case on" 2>/dev/null # ignore strict case sensitivity + bind "set bell-style none" 2>/dev/null # turn off audible alerts + bind "set show-all-if-ambiguous on" 2>/dev/null # show completion with double tap +fi + +# add scripts to path +export PATH="$AM_PROMPT/bash/scripts:$PATH" + +# evaluate eval scripts +for EVAL_SCRIPT in $AM_PROMPT/bash/scripts/eval/*; do + . "$EVAL_SCRIPT" +done + +# test for user bashrc +if [ -f $AM_PROMPT/user/bashrc ]; then + . "$AM_PROMPT/user/bashrc" +fi diff --git a/src/bash/install/centos.sh b/src/bash/install/centos.sh new file mode 100755 index 0000000..9f5a603 --- /dev/null +++ b/src/bash/install/centos.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +. "$AM_PROMPT/bash/install/linux.sh" diff --git a/src/bash/install/darwin.sh b/src/bash/install/darwin.sh new file mode 100755 index 0000000..dc2fa93 --- /dev/null +++ b/src/bash/install/darwin.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +__am_prompt_install_darwin() { + local BREWS='bash bash-completion' + + set +e + + for pkg in $BREWS; do + if brew list -1 | grep -q "^${pkg}\$"; then + $ECHO "${CLR_SUCCESS}upgrading: $pkg...${CLR_CLEAR}" + brew upgrade $pkg 2>/dev/null + brew link --overwrite $pkg 2>/dev/null + else + $ECHO "${CLR_SUCCESS}installing: $pkg...${CLR_CLEAR}" + brew install $pkg + fi + done +} + +__am_prompt_install_darwin diff --git a/src/bash/install/debian.sh b/src/bash/install/debian.sh new file mode 100755 index 0000000..9f5a603 --- /dev/null +++ b/src/bash/install/debian.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +. "$AM_PROMPT/bash/install/linux.sh" diff --git a/src/bash/install/fedora.sh b/src/bash/install/fedora.sh new file mode 100755 index 0000000..eebb805 --- /dev/null +++ b/src/bash/install/fedora.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +. "$AM_PROMPT/bash/install/centos.sh" diff --git a/src/bash/install/linux.sh b/src/bash/install/linux.sh new file mode 100755 index 0000000..9d51995 --- /dev/null +++ b/src/bash/install/linux.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +__am_prompt_install_linux() { + local BREWS='bash bash-completion' + + set +e + + for pkg in $BREWS; do + if brew list -1 | grep -q "^${pkg}\$"; then + $ECHO "${CLR_SUCCESS}upgrading: $pkg...${CLR_CLEAR}" + brew upgrade $pkg 2>/dev/null + brew link --overwrite $pkg 2>/dev/null + else + $ECHO "${CLR_SUCCESS}installing: $pkg...${CLR_CLEAR}" + brew install $pkg + fi + done +} + +__am_prompt_install_linux diff --git a/src/bash/install/linuxmint.sh b/src/bash/install/linuxmint.sh new file mode 100755 index 0000000..9f5a603 --- /dev/null +++ b/src/bash/install/linuxmint.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +. "$AM_PROMPT/bash/install/linux.sh" diff --git a/src/bash/install/ubuntu.sh b/src/bash/install/ubuntu.sh new file mode 100755 index 0000000..92a2828 --- /dev/null +++ b/src/bash/install/ubuntu.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +. "$AM_PROMPT/bash/install/debian.sh" diff --git a/src/scripts/Darwin/eval/docker-completion b/src/bash/scripts/darwin/eval/docker-completion similarity index 64% rename from src/scripts/Darwin/eval/docker-completion rename to src/bash/scripts/darwin/eval/docker-completion index f9f9477..38dde1e 100755 --- a/src/scripts/Darwin/eval/docker-completion +++ b/src/bash/scripts/darwin/eval/docker-completion @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh if [ -d /Applications/Docker.app/Contents/Resources/etc ]; then local DOCKER_PATH=/Applications/Docker.app/Contents/Resources/etc @@ -7,7 +7,7 @@ elif [ -d "$HOME/Applications/Docker.app/Contents/Resources/etc" ]; then fi if [ ! -z "${DOCKER_PATH:-}" ]; then - source "$DOCKER_PATH/docker.bash-completion" - source "$DOCKER_PATH/docker-machine.bash-completion" - source "$DOCKER_PATH/docker-compose.bash-completion" + . "$DOCKER_PATH/docker.bash-completion" + . "$DOCKER_PATH/docker-machine.bash-completion" + . "$DOCKER_PATH/docker-compose.bash-completion" fi diff --git a/src/scripts/edit-bashrc b/src/bash/scripts/edit-bashrc similarity index 81% rename from src/scripts/edit-bashrc rename to src/bash/scripts/edit-bashrc index a901f0a..6623e26 100755 --- a/src/scripts/edit-bashrc +++ b/src/bash/scripts/edit-bashrc @@ -1,6 +1,6 @@ #!/usr/bin/env bash -__am-prompt-edit-bashrc() { +__am_prompt_edit_bashrc() { local BASHRC_PATH="$AM_PROMPT/user/bashrc" if [ ! -f "$BASHRC_PATH" ]; then @@ -11,4 +11,4 @@ __am-prompt-edit-bashrc() { ${EDITOR:-vi} "$BASHRC_PATH" } -__am-prompt-edit-bashrc +__am_prompt_edit_bashrc diff --git a/src/bash/scripts/eval/set-completion b/src/bash/scripts/eval/set-completion new file mode 100755 index 0000000..af3deab --- /dev/null +++ b/src/bash/scripts/eval/set-completion @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# setup completion +if [ -f "$LOCAL_PREFIX/etc/bash_completion" ]; then + . "$LOCAL_PREFIX/etc/bash_completion" +elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion +elif [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion +fi + +if type gulp 1>/dev/null 2>&1; then + . <(gulp --completion=bash) +fi + +if type grunt 1>/dev/null 2>&1; then + . <(grunt --completion=bash) +fi + +if type kubectl 1>/dev/null 2>&1; then + . <(kubectl completion bash) +fi + +if type helm 1>/dev/null 2>&1; then + . <(helm completion bash) +fi + +if type minikube 1>/dev/null 2>&1; then + . <(minikube completion bash) +fi + +if type nvm 1>/dev/null 2>&1; then + . <(npm completion) +fi + +__am_prompt_dotnet_bash_complete() +{ + local WORD=${COMP_WORDS[COMP_CWORD]} + + local COMPLETIONS="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)" + + if [ $? -ne 0 ]; then + COMPLETIONS="" + fi + + COMPREPLY=( $(compgen -W "$COMPLETIONS" -- "$WORD") ) +} + +if type dotnet 1>/dev/null 2>&1; then + complete -f -F __am_prompt_dotnet_bash_complete dotnet +fi + +# determine if completions exist +if [ ! -d "$AM_PROMPT/bash/completions" ]; then + + # move on immediately + return +fi + +# iterate over each completion +for AM_COMPLETION in $AM_PROMPT/bash/completions/*; do + + # source the completion + . "$AM_COMPLETION" +done diff --git a/src/bash/scripts/eval/set-gcloud-path b/src/bash/scripts/eval/set-gcloud-path new file mode 100755 index 0000000..8df4a88 --- /dev/null +++ b/src/bash/scripts/eval/set-gcloud-path @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +__am_prompt_set_gcloud_path() { + + # detect gcloud + if ! test type gcloud 1>/dev/null 2>&1; then + + # attempt to discover the path + if [ ! -f "$HOME/.gcloud/bin/gcloud" ]; then + + # no gcloud installed + return + fi + + # add gcloud to the path + export PATH="$HOME/.gcloud/bin":$PATH + fi + + local GCLOUD_CMD=$(command -v gcloud) + local GCLOUD_DIR=$(dirname "$GCLOUD_CMD") + + local GCLOUD_PATH_INC="$GCLOUD_DIR/path.bash.inc" + local GCLOUD_COMPLETION_INC="$GCLOUD_DIR/completion.bash.inc" + + # detect the gcloud path + if [ ! -f "$BASH_COMPLETION_DIR/_gcloud-path" ]; then + + # detect gcloud path completion + if [ -f "$GCLOUD_PATH_INC" ]; then + + # link the gcloud path to the completion dir + ln -s $GCLOUD_PATH_INC "$BASH_COMPLETION_DIR/_gcloud-path" + + # source the path + . "$BASH_COMPLETION_DIR/_gcloud-path" + fi + fi + + # detect the gcloud completion path + if [ ! -f "$BASH_COMPLETION_DIR/_gcloud-completion" ]; then + + # detect gcloud command completion + if [ -f "$GCLOUD_COMPLETION_INC" ]; then + + # link the gcloud completion to the completion dir + ln -s $GCLOUD_COMPLETION_INC "$BASH_COMPLETION_DIR/_gcloud-completion" + + # source the path + . "$BASH_COMPLETION_DIR/_gcloud-completion" + fi + fi +} + +__am_prompt_set_gcloud_path diff --git a/src/scripts/eval/set-prompt b/src/bash/scripts/eval/set-prompt similarity index 51% rename from src/scripts/eval/set-prompt rename to src/bash/scripts/eval/set-prompt index 349f17c..6995662 100755 --- a/src/scripts/eval/set-prompt +++ b/src/bash/scripts/eval/set-prompt @@ -1,6 +1,6 @@ #!/usr/bin/env bash -__am-prompt-emit-prompt-arrow() { +__am_prompt_emit_prompt_arrow() { # set the default color local CLR_PROMPT=$CLR_USER_PROMPT @@ -26,45 +26,18 @@ __am-prompt-emit-prompt-arrow() { fi } -__am-prompt-set-prompt() { - if [ -f "$LOCAL_PREFIX/etc/bash_completion" ]; then - source "$LOCAL_PREFIX/etc/bash_completion" - elif [ -f /etc/bash_completion ]; then - source /etc/bash_completion - elif [ -f /usr/share/bash-completion/bash_completion ]; then - source /usr/share/bash-completion/bash_completion - fi - - # source completions - for AM_COMPLETION in $AM_PROMPT/completions/*; do - source "$AM_COMPLETION" - done +__am_prompt_set_prompt() { # set the window title echo -ne "\033]0;${USER}@${HOSTNAME%%.*} ${PWD}\007" if ! type git 1>/dev/null 2>&1; then - export PROMPT_COMMAND='"\n\u@\h : \w\n" "$(__am-prompt-emit-prompt-arrow)"' + export PROMPT_COMMAND='"\n\u@\h : \w\n" "$(__am_prompt_emit_prompt_arrow)"' else # use the git prompt with the prompt arrow - export PROMPT_COMMAND='__posh_git_ps1 "\n\u@\h : \w\n" "$(__am-prompt-emit-prompt-arrow)"' - fi -} - -__am-prompt-set-nvm() { - NVM_PATH=$(brew --prefix nvm 2>/dev/null) - - if [ ! -d ${NVM_PATH} ]; then - NVM_PATH=$HOME/.nvm - fi - - if [ -f "$NVM_PATH/nvm.sh" ]; then - export NVM_DIR="${HOME}/.nvm" - source "$NVM_PATH/nvm.sh" - eval "$(npm completion)" + export PROMPT_COMMAND='__posh_git_ps1 "\n\u@\h : \w\n" "$(__am_prompt_emit_prompt_arrow)"' fi } -__am-prompt-set-prompt -__am-prompt-set-nvm +__am_prompt_set_prompt diff --git a/src/bash/scripts/eval/source-os b/src/bash/scripts/eval/source-os new file mode 100755 index 0000000..3b9d360 --- /dev/null +++ b/src/bash/scripts/eval/source-os @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +__am_prompt_source_os() { + + local UNAME=$(uname | tr '[:upper:]' '[:lower:]') + local UNAME_PATH="$HOME/.am/prompt/bash/scripts/$UNAME" + + if [ -f /etc/os-release ]; then + . /etc/os-release + + local UNAME="$ID" + local UNAME_PATH="$HOME/.am/prompt/bash/scripts/$UNAME" + fi + + if [ -d "$UNAME_PATH" ]; then + export PATH="$UNAME_PATH:$PATH" + fi + + if [ -d "$UNAME_PATH/eval" ]; then + for EVAL_SCRIPT in $UNAME_PATH/eval/*; do + . "$EVAL_SCRIPT" + done + fi + + export AM_PROMPT_OS=$UNAME +} + +__am_prompt_source_os diff --git a/src/scripts/Darwin/theme b/src/scripts/Darwin/theme deleted file mode 100755 index 17da5c2..0000000 --- a/src/scripts/Darwin/theme +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -open $HOME/.am/prompt/themes/terminal/Monokai.terminal diff --git a/src/scripts/cls b/src/scripts/cls deleted file mode 100755 index 59d72d6..0000000 --- a/src/scripts/cls +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -clear diff --git a/src/scripts/do-repeat b/src/scripts/do-repeat deleted file mode 100755 index 29bc731..0000000 --- a/src/scripts/do-repeat +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -__am-prompt-do-repeat() { - local COUNT=$1 - local CMD="${*:2}" - - for (( CURRENT=1; CURRENT<=$COUNT; CURRENT++ )); do $CMD; done -} - -__am-prompt-do-repeat $@ diff --git a/src/scripts/eval/set-completion b/src/scripts/eval/set-completion deleted file mode 100755 index 2d150b2..0000000 --- a/src/scripts/eval/set-completion +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -if type gulp 1>/dev/null 2>&1; then - eval "$(gulp --completion=bash)" 1>/dev/null 2>&1; -fi - -if type grunt 1>/dev/null 2>&1; then - eval "$(grunt --completion=bash)" 1>/dev/null 2>&1; -fi - -if type kubectl 1>/dev/null 2>&1; then - eval "$(kubectl completion bash)" 1>/dev/null 2>&1; -fi - -if type helm 1>/dev/null 2>&1; then - eval "$(helm completion bash)" 1>/dev/null 2>&1; -fi - -if type minikube 1>/dev/null 2>&1; then - eval "$(minikube completion bash)" 1>/dev/null 2>&1; -fi - -__am-prompt-dotnet_bash_complete() { - local WORD=${COMP_WORDS[COMP_CWORD]} - local DOTNET_PATH=${COMP_WORDS[1]} - - local COMPLETIONS=("$(dotnet complete --position ${COMP_POINT} "${COMP_LINE}")") - - COMPREPLY=( $(compgen -W "$COMPLETIONS" -- "$WORD") ) -} - -complete -f -F __am-prompt-dotnet_bash_complete dotnet diff --git a/src/scripts/eval/set-gcloud-path b/src/scripts/eval/set-gcloud-path deleted file mode 100755 index c4d49cd..0000000 --- a/src/scripts/eval/set-gcloud-path +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -__am-prompt-set-gcloud-path() { - local GCLOUD_PATH_INC="$HOME/.gcloud/path.bash.inc" - local GCLOUD_COMPLETION_INC="$HOME/.gcloud/completion.bash.inc" - - if [ -f "$GCLOUD_PATH_INC" ]; then - source "$GCLOUD_PATH_INC" - fi - - if [ -f "$GCLOUD_COMPLETION_INC" ]; then - source "$GCLOUD_COMPLETION_INC" - fi -} - -__am-prompt-set-gcloud-path diff --git a/src/scripts/eval/source-os b/src/scripts/eval/source-os deleted file mode 100755 index cd843cf..0000000 --- a/src/scripts/eval/source-os +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -__am-prompt-source-os() { - local UNAME=$(uname) - local UNAME_PATH="$HOME/.am/prompt/scripts/$UNAME" - - if [ -f /etc/os-release ]; then - source /etc/os-release - - local UNAME="$ID" - local UNAME_PATH="$HOME/.am/prompt/scripts/$ID" - fi - - if [ -d "$UNAME_PATH" ]; then - export PATH="$UNAME_PATH:$PATH" - fi - - if [ -d "$UNAME_PATH/eval" ]; then - for EVAL_FILE in $UNAME_PATH/eval/*; do - source "$EVAL_FILE" - done - fi - - export AM_PROMPT_OS=$UNAME -} - -__am-prompt-source-os diff --git a/src/scripts/la b/src/scripts/la deleted file mode 100755 index e0e6180..0000000 --- a/src/scripts/la +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -ls -la $@ diff --git a/src/scripts/ll b/src/scripts/ll deleted file mode 100755 index d721609..0000000 --- a/src/scripts/ll +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -ls -lh $@ diff --git a/src/scripts/lla b/src/scripts/lla deleted file mode 100755 index e5858f6..0000000 --- a/src/scripts/lla +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -ls -lha $@ diff --git a/src/scripts/lsp b/src/scripts/lsp deleted file mode 100755 index 6e6c9f9..0000000 --- a/src/scripts/lsp +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -ls -p $@ diff --git a/src/scripts/minikube-start b/src/scripts/minikube-start deleted file mode 100755 index 9084597..0000000 --- a/src/scripts/minikube-start +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# start minikube with rbac and psp -minikube start \ - --extra-config=apiserver.authorization-mode=RBAC \ - --extra-config=apiserver.enable-admission-plugins="PodSecurityPolicy" diff --git a/src/scripts/rd b/src/scripts/rd deleted file mode 100755 index 15a4414..0000000 --- a/src/scripts/rd +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -rm -r $@ diff --git a/src/scripts/update-prompt b/src/scripts/update-prompt deleted file mode 100755 index 39d87bc..0000000 --- a/src/scripts/update-prompt +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -__am-prompt-update-prompt() { - local SHA_PATH=$HOME/.am/prompt/.sha - local SHA=$(git-sha) - - if [ "${1:-}" = "--force" ]; then - rm -rf $SHA_PATH 1>/dev/null 2>&1 - fi - - if [ -f ${SHA_PATH:-} ]; then - local CURRENT_SHA=$(cat $SHA_PATH) - - if [ -z ${SHA:-} ]; then - echo -e "${CLR_FAIL}prompt: cannot retrieve SHA of latest version. Are you connected to the internet?${CLR_CLEAR}" - return 1 - fi - - if [ "${SHA:-}" = "${CURRENT_SHA:-}" ]; then - echo -e "${CLR_SUCCESS}prompt: latest version already installed: ${SHA}.${CLR_CLEAR}" - return 0 - fi - fi - - if [ "${1:-}" = "--dry-run" ]; then - echo -e "${CLR_WARN}prompt: a new version of prompt is available: ${SHA}." - echo -e " - run the update-prompt command line tool to upgrade${CLR_CLEAR}" - return 0 - fi - - remove-backup - - local CHANGELOG_URI="https://github.com/automotivemastermind/prompt/blob/master/CHANGELOG.md" - local UPDATE_URI="https://github.com/automotivemastermind/prompt/archive/master.tar.gz" - local UPDATE_TEMP=$(mktemp -d) - - pushd "$UPDATE_TEMP" 1>/dev/null - curl -skL $UPDATE_URI | tar zx - pushd prompt-master 1>/dev/null - ./install.sh - popd 1>/dev/null - popd 1>/dev/null - - rm -rf "$UPDATE_TEMP" 1>/dev/null - - open-url $CHANGELOG_URI 1>/dev/null -} - -__am-prompt-update-prompt $@ diff --git a/src/sh/install/centos.sh b/src/sh/install/centos.sh new file mode 100755 index 0000000..9cb1f55 --- /dev/null +++ b/src/sh/install/centos.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env sh + +__am_prompt_install_centos() { + local YUM=$(command -v dnf 2>/dev/null || command -v yum) + local PACKAGES='curl file git which' + + $ECHO "${CLR_SUCCESS}installing development tools...${CLR_CLEAR}" + sudo $YUM groupinstall -y "Development Tools" + + for pkg in $PACKAGES; do + $ECHO "${CLR_SUCCESS}installing $pkg...${CLR_CLEAR}" + sudo $YUM install -y ${pkg} + done + + . "$AM_PROMPT/sh/install/linux.sh" +} + +__am_prompt_install_centos diff --git a/src/sh/install/darwin.sh b/src/sh/install/darwin.sh new file mode 100755 index 0000000..cbc4484 --- /dev/null +++ b/src/sh/install/darwin.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env sh + +__am_prompt_install_darwin() { + local BREWS='openssl git go nvm python' + + if ! type brew 1>/dev/null 2>&1; then + $ECHO "${CLR_SUCCESS}installing homebrew...${CLR_CLEAR}" + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + fi + + $ECHO "${CLR_SUCCESS}updating homebrew...${CLR_CLEAR}" + brew update + + set +e + + for pkg in $BREWS; do + if brew list -1 | grep -q "^${pkg}\$"; then + $ECHO "${CLR_SUCCESS}upgrading: $pkg...${CLR_CLEAR}" + brew upgrade $pkg 2>/dev/null + brew link --overwrite $pkg 2>/dev/null + else + $ECHO "${CLR_SUCCESS}installing: $pkg...${CLR_CLEAR}" + brew install $pkg + fi + done + + local NVM_PATH=$(brew --prefix nvm) + + if [ -f "$NVM_PATH/nvm.sh" ]; then + $ECHO "${CLR_SUCCESS}setting up nvm...${CLR_CLEAR}" + export NVM_DIR="${HOME}/.nvm" + . "$NVM_PATH/nvm.sh" + nvm install --lts 2>/dev/null + nvm use --lts --delete-prefix --silent 2>/dev/null + fi + + $ECHO "${CLR_SUCCESS}setting git credential helper to use the macOS keychain${CLR_CLEAR}" + git config --system credential.helper osxkeychain +} + +__am_prompt_install_darwin diff --git a/src/sh/install/debian.sh b/src/sh/install/debian.sh new file mode 100755 index 0000000..f2790aa --- /dev/null +++ b/src/sh/install/debian.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env sh + +__am_prompt_install_debian() { + local PACKAGES='build-essential curl file git' + + $ECHO "${CLR_SUCCESS}updating software repositories...${CLR_CLEAR}" + sudo apt-get update + + for pkg in $PACKAGES; do + $ECHO "${CLR_SUCCESS}installing $pkg...${CLR_CLEAR}" + sudo apt-get install -y ${pkg} + done + + $ECHO "${CLR_SUCCESS}removing unnecessary dependencies...${CLR_CLEAR}" + sudo apt-get autoremove -y + + . "$AM_PROMPT/sh/install/linux.sh" +} + +__am_prompt_install_debian + diff --git a/src/sh/install/fedora.sh b/src/sh/install/fedora.sh new file mode 100755 index 0000000..e9d8b3b --- /dev/null +++ b/src/sh/install/fedora.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +. "$AM_PROMPT/sh/install/centos.sh" diff --git a/src/sh/install/linux.sh b/src/sh/install/linux.sh new file mode 100755 index 0000000..e5066b8 --- /dev/null +++ b/src/sh/install/linux.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env sh + +__am_prompt_install_linux() { + local BREWS='gcc git' + + if ! type brew 1>/dev/null 2>&1; then + $ECHO "${CLR_SUCCESS}installing homebrew...${CLR_CLEAR}" + sh -c "yes | $(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh) && brew config" + + . "$AM_PROMPT/sh/scripts/eval/set-brew-path" + fi + + $ECHO "${CLR_SUCCESS}updating homebrew...${CLR_CLEAR}" + brew update + + set +e + + for pkg in $BREWS; do + if brew list -1 | grep -q "^${pkg}\$"; then + $ECHO "${CLR_SUCCESS}upgrading: $pkg...${CLR_CLEAR}" + brew upgrade $pkg 2>/dev/null + brew link --overwrite $pkg 2>/dev/null + else + $ECHO "${CLR_SUCCESS}installing: $pkg...${CLR_CLEAR}" + brew install $pkg + fi + done + + set -e + + curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash + + export NVM_DIR="$HOME/.nvm" + . "$NVM_DIR/nvm.sh" + + nvm install --lts + nvm use --lts --delete-prefix +} + +__am_prompt_install_linux diff --git a/src/sh/install/linuxmint.sh b/src/sh/install/linuxmint.sh new file mode 100755 index 0000000..108683b --- /dev/null +++ b/src/sh/install/linuxmint.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +__am_prompt_install_mint() { + local PACKAGES='build-essential curl file git' + + $ECHO "${CLR_SUCCESS}updating software repositories...${CLR_CLEAR}" + sudo apt-get update + + for pkg in $PACKAGES; do + $ECHO "${CLR_SUCCESS}installing $pkg...${CLR_CLEAR}" + sudo apt-get install -y ${pkg} + done + + $ECHO "${CLR_SUCCESS}removing unnecessary dependencies...${CLR_CLEAR}" + sudo apt-get autoremove -y + + . "$AM_PROMPT/sh/install/linux.sh" +} + +__am_prompt_install_mint diff --git a/src/sh/install/ubuntu.sh b/src/sh/install/ubuntu.sh new file mode 100755 index 0000000..42473af --- /dev/null +++ b/src/sh/install/ubuntu.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +. "$AM_PROMPT/sh/install/debian.sh" diff --git a/src/bashrc b/src/sh/profile old mode 100644 new mode 100755 similarity index 68% rename from src/bashrc rename to src/sh/profile index 68ad707..521edff --- a/src/bashrc +++ b/src/sh/profile @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # set globals for colors export CLR_CLEAR='\033[0m' # DEFAULT COLOR @@ -21,6 +21,38 @@ export CLR_BRIGHT_MAGENTA='\033[1;35m' # BRIGHT MAGENTA (PURPLE) export CLR_BRIGHT_CYAN='\033[1;36m' # BRIGHT CYAN export CLR_BRIGHT_WHITE='\033[1;37m' # BRIGHT WHITE +# determine if this is not a tty +if [ ! -t 1 ]; then + + # wipe out all of the colors + export CLR_CLEAR='' + export CLR_BLACK='' + export CLR_RED='' + export CLR_GREEN='' + export CLR_YELLOW='' + export CLR_BLUE='' + export CLR_MAGENTA='' + export CLR_CYAN='' + export CLR_WHITE='' + export CLR_BRIGHT_BLACK='' + export CLR_BRIGHT_RED='' + export CLR_BRIGHT_GREEN='' + export CLR_BRIGHT_YELLOW='' + export CLR_BRIGHT_BLUE='' + export CLR_BRIGHT_MAGENTA='' + export CLR_BRIGHT_CYAN='' + export CLR_BRIGHT_WHITE='' +else + # enable colors for various commands + export TERM=xterm-256color + export GREP_COLOR='1;32' + export CLICOLOR=1 + alias grep="grep --color=auto" + + # change ls colors to be more like original unix/linux + export LSCOLORS="ExGxBxDxCxEgEdxbxgxcxd" +fi + export CLR_SUCCESS=$CLR_BRIGHT_GREEN # COLOR FOR SUCCESS MESSAGES export CLR_FAIL=$CLR_BRIGHT_RED # COLOR FOR ERROR MESSAGES export CLR_WARN=$CLR_BRIGHT_YELLOW # COLOR FOR WARNING MESSAGES @@ -31,25 +63,9 @@ export CLR_STAFF_PROMPT=$CLR_BRIGHT_GREEN # COLOR OF THE PROMPT FOR STAFF export CLR_USER_PROMPT=$CLR_BRIGHT_BLUE # COLOR OF THE PROMPT FOR USERS export CLR_SSH_PROMPT=$CLR_BRIGHT_MAGENTA # COLOR OF THE PROMPT FOR SSH -# shell options -shopt -s checkwinsize # check window size on script exit -shopt -s cdable_vars # enable change directory to a variable value -shopt -s extglob # enable extended glob patterns -shopt -s globstar # enable glob ** expansion - -# enable colors for various commands -export TERM=xterm-256color -export GREP_COLOR='1;32' -export CLICOLOR=1 -alias grep="grep --color=auto" - -# change ls colors to be more like original unix/linux -export LSCOLORS="ExGxBxDxCxEgEdxbxgxcxd" - +# use code as the default editor if type code 1>/dev/null 2>&1; then export EDITOR='code --wait' -else - export EDITOR='nano' fi export HISTCONTROL=ignoredubs @@ -62,22 +78,16 @@ else export LOCAL_PREFIX=/usr/local fi -# system binds for bash completion (for interactive terminals) -if [ -t 1 ]; then - bind "set completion-ignore-case on" 2>/dev/null # ignore strict case sensitivity - bind "set bell-style none" 2>/dev/null # turn off audible alerts - bind "set show-all-if-ambiguous on" 2>/dev/null # show completion with double tap -fi - +# add am home export AM_HOME="$HOME/.am" export AM_PROMPT="$AM_HOME/prompt" # add scripts to path -export PATH="$AM_PROMPT/scripts:$PATH" +export PATH="$AM_PROMPT/sh/scripts:$PATH" # test for user variables if [ -f $AM_PROMPT/user/variables ]; then - source "$AM_PROMPT/user/variables" + . "$AM_PROMPT/user/variables" fi # test for prompt bin @@ -87,15 +97,10 @@ if [ -d "$AM_PROMPT/user/bin" ]; then fi # evaluate eval scripts -for EVAL_SCRIPT in $AM_PROMPT/scripts/eval/*; do - source "$EVAL_SCRIPT" +for EVAL_SCRIPT in $AM_PROMPT/sh/scripts/eval/*; do + . "$EVAL_SCRIPT" done -# test for user bashrc -if [ -f $AM_PROMPT/user/bashrc ]; then - source "$AM_PROMPT/user/bashrc" -fi - # aliases # -- prompt for overwrites alias cp='cp -i' diff --git a/src/scripts/add-bookmark b/src/sh/scripts/add-bookmark similarity index 73% rename from src/scripts/add-bookmark rename to src/sh/scripts/add-bookmark index f42ab8b..679d7b4 100755 --- a/src/scripts/add-bookmark +++ b/src/sh/scripts/add-bookmark @@ -1,11 +1,11 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-add-bookmark-usage() { +__am_prompt_add_bookmark_usage() { echo 'add-bookmark ' echo ' name : a name for your bookmark' } -__am-prompt-add-bookmark() { +__am_prompt_add_bookmark() { # make sure that a bookmark was specified. if [ -z ${1:-} ]; then echo 'add-bookmark: missing ' @@ -13,7 +13,7 @@ __am-prompt-add-bookmark() { fi if [ "${1:-}" = "--help" ]; then - __am-prompt-add-bookmark-usage + __am_prompt_add_bookmark_usage return fi @@ -23,7 +23,7 @@ __am-prompt-add-bookmark() { echo "add-bookmark: adding bookmark $BOOKMARK" echo $BOOKMARK >> "$HOME/.am/prompt/user/bookmarks.sh" - source "$HOME/.am/prompt/user/bookmarks.sh" + . "$HOME/.am/prompt/user/bookmarks.sh" } -__am-prompt-add-bookmark $@ +__am_prompt_add_bookmark $@ diff --git a/src/scripts/add-var b/src/sh/scripts/add-var similarity index 76% rename from src/scripts/add-var rename to src/sh/scripts/add-var index e7e4295..b677df5 100755 --- a/src/scripts/add-var +++ b/src/sh/scripts/add-var @@ -1,27 +1,27 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-add-var-usage() { +__am_prompt_add_var_usage() { echo '[add-var|set-var] ' echo ' name : a name for your variable' echo ' value : a value for your variable' } -__am-prompt-add-var() { +__am_prompt_add_var() { # make sure that a bookmark was specified. if [ -z ${1:-} ]; then echo 'add-var: missing ' - __am-prompt-add-var-usage + __am_prompt_add_var_usage return fi if [ "${1:-}" = "--help" ]; then - __am-prompt-add-var-usage + __am_prompt_add_var_usage return fi if [ -z ${2:-} ]; then echo 'add-var: missing ' - __am-prompt-add-var-usage + __am_prompt_add_var_usage return fi @@ -33,7 +33,7 @@ __am-prompt-add-var() { echo 'Adding varable: $VARIABLE' echo >> "$VAR_PATH" echo "$VARIABLE" >> "$VAR_PATH" - source "$VAR_PATH" + . "$VAR_PATH" } -__am-prompt-add-var $@ +__am_prompt_add_var $@ diff --git a/src/scripts/aws-install b/src/sh/scripts/aws-install similarity index 73% rename from src/scripts/aws-install rename to src/sh/scripts/aws-install index f3b896e..6640c78 100755 --- a/src/scripts/aws-install +++ b/src/sh/scripts/aws-install @@ -1,12 +1,12 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-aws-install() { - local BREWS=(awscli aws-sam-cli) +__am_prompt_aws_install() { + local BREWS='awscli aws-sam-cli' brew tap aws/tap brew update - for pkg in "${BREWS[@]}"; do + for pkg in $BREWS; do if brew list -1 | grep -q "^${pkg}\$"; then echo "upgrading: $pkg..." brew upgrade $pkg 2>/dev/null @@ -23,4 +23,4 @@ __am-prompt-aws-install() { aws configure } -__am-prompt-aws-install +__am_prompt_aws_install diff --git a/src/scripts/centos/minikube-install b/src/sh/scripts/centos/minikube-install similarity index 92% rename from src/scripts/centos/minikube-install rename to src/sh/scripts/centos/minikube-install index 7bda09e..feb1d13 100755 --- a/src/scripts/centos/minikube-install +++ b/src/sh/scripts/centos/minikube-install @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # install the hypervisor sudo yum install -y qemu-kvm libvirt libvirt-python libguestfs-tools virt-install diff --git a/src/sh/scripts/cls b/src/sh/scripts/cls new file mode 100755 index 0000000..02f136b --- /dev/null +++ b/src/sh/scripts/cls @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +clear diff --git a/src/scripts/Darwin/eval/add-ssh-keys b/src/sh/scripts/darwin/eval/add-ssh-keys similarity index 54% rename from src/scripts/Darwin/eval/add-ssh-keys rename to src/sh/scripts/darwin/eval/add-ssh-keys index ba72344..2c84dde 100755 --- a/src/scripts/Darwin/eval/add-ssh-keys +++ b/src/sh/scripts/darwin/eval/add-ssh-keys @@ -1,3 +1,3 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ssh-add -A 2>/dev/null diff --git a/src/scripts/Darwin/flush-dns b/src/sh/scripts/darwin/flush-dns similarity index 74% rename from src/scripts/Darwin/flush-dns rename to src/sh/scripts/darwin/flush-dns index 0e8a60e..063b032 100755 --- a/src/scripts/Darwin/flush-dns +++ b/src/sh/scripts/darwin/flush-dns @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh dscacheutil -flushcache sudo killall -HUP mDNSResponder diff --git a/src/scripts/Darwin/hide-all b/src/sh/scripts/darwin/hide-all similarity index 78% rename from src/scripts/Darwin/hide-all rename to src/sh/scripts/darwin/hide-all index d24398f..f93ac4a 100755 --- a/src/scripts/Darwin/hide-all +++ b/src/sh/scripts/darwin/hide-all @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh defaults write com.apple.finder AppleShowAllFiles FALSE killall Finder diff --git a/src/scripts/Darwin/minikube-install b/src/sh/scripts/darwin/minikube-install similarity index 85% rename from src/scripts/Darwin/minikube-install rename to src/sh/scripts/darwin/minikube-install index 3386d11..0969924 100755 --- a/src/scripts/Darwin/minikube-install +++ b/src/sh/scripts/darwin/minikube-install @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # setup the hypervisor brew install hyperkit diff --git a/src/scripts/Darwin/show-all b/src/sh/scripts/darwin/show-all similarity index 78% rename from src/scripts/Darwin/show-all rename to src/sh/scripts/darwin/show-all index 7cb6c3d..b6861fa 100755 --- a/src/scripts/Darwin/show-all +++ b/src/sh/scripts/darwin/show-all @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh defaults write com.apple.finder AppleShowAllFiles TRUE killall Finder diff --git a/src/sh/scripts/darwin/theme b/src/sh/scripts/darwin/theme new file mode 100755 index 0000000..9364880 --- /dev/null +++ b/src/sh/scripts/darwin/theme @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +PROMPT_THEME=${1:-"monokai"} + +if [ ! -f "${PROMPT_THEME:-}" ]; then + echo "${CLR_FAIL}The theme $PROMPT_THEME is not supported.${CLR_CLEAR}" + exit 1 +fi + +open $HOME/.am/prompt/themes/terminal/$PROMPT_THEME.terminal diff --git a/src/scripts/debian/minikube-install b/src/sh/scripts/debian/minikube-install similarity index 92% rename from src/scripts/debian/minikube-install rename to src/sh/scripts/debian/minikube-install index 3b03785..c375262 100755 --- a/src/scripts/debian/minikube-install +++ b/src/sh/scripts/debian/minikube-install @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # install the hypervisor sudo apt-get install -y qemu-kvm libvirt-clients libvirt-daemon-system diff --git a/src/sh/scripts/do-repeat b/src/sh/scripts/do-repeat new file mode 100755 index 0000000..0c8c460 --- /dev/null +++ b/src/sh/scripts/do-repeat @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +__am_prompt_do_repeat() { + local COUNT=$1 + shift + + local CMD="$@" + + for iteration in seq 1 $COUNT; do + $CMD + done +} + +__am_prompt_do_repeat $@ diff --git a/src/scripts/docker-gc b/src/sh/scripts/docker-gc similarity index 52% rename from src/scripts/docker-gc rename to src/sh/scripts/docker-gc index c768807..4ceaabd 100755 --- a/src/scripts/docker-gc +++ b/src/sh/scripts/docker-gc @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh docker-rm docker-rmi diff --git a/src/scripts/docker-rm b/src/sh/scripts/docker-rm similarity index 79% rename from src/scripts/docker-rm rename to src/sh/scripts/docker-rm index ba18f73..d00b9f9 100755 --- a/src/scripts/docker-rm +++ b/src/sh/scripts/docker-rm @@ -1,3 +1,3 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh docker rm -v $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null diff --git a/src/scripts/docker-rmi b/src/sh/scripts/docker-rmi similarity index 79% rename from src/scripts/docker-rmi rename to src/sh/scripts/docker-rmi index 62e8355..6a5c54e 100755 --- a/src/scripts/docker-rmi +++ b/src/sh/scripts/docker-rmi @@ -1,3 +1,3 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null diff --git a/src/scripts/docker-update b/src/sh/scripts/docker-update similarity index 79% rename from src/scripts/docker-update rename to src/sh/scripts/docker-update index c1424cd..4511043 100755 --- a/src/scripts/docker-update +++ b/src/sh/scripts/docker-update @@ -1,3 +1,3 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh docker images | grep -v REPOSITORY | awk '{print $1}' | xargs -L1 docker pull diff --git a/src/scripts/dotnet-install b/src/sh/scripts/dotnet-install similarity index 64% rename from src/scripts/dotnet-install rename to src/sh/scripts/dotnet-install index d687002..85b8fa2 100755 --- a/src/scripts/dotnet-install +++ b/src/sh/scripts/dotnet-install @@ -1,6 +1,6 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-safe-exec() { +__am_prompt_safe_exec() { local CMD=$1 shift @@ -13,33 +13,37 @@ __am-prompt-safe-exec() { fi } -__am-prompt-dotnet-install() { +__am_prompt_dotnet_install() { + local DOTNET_RESET=0 - local DOTNET_CHANNELS=() - local DOTNET_VERSIONS=() + local DOTNET_CHANNELS='' + local DOTNET_VERSIONS='' # continue testing for arguments - while [[ $# > 0 ]]; do + while :; do case $1 in --reset|--clean) DOTNET_RESET=1 ;; --channel) - DOTNET_CHANNELS+=($2) shift + DOTNET_CHANNELS="$DOTNET_CHANNELS $1" ;; --version) - DOTNET_VERSIONS+=($2) shift + DOTNET_VERSIONS="$DOTNET_VERSIONS $1" ;; --) shift break ;; - *) + ?*) export DOTNET_INSTALL_DIR=$1 break ;; + *) + break + ;; esac shift done @@ -48,11 +52,11 @@ __am-prompt-dotnet-install() { export DOTNET_INSTALL_DIR="$HOME/.dotnet" fi - if [ ${#DOTNET_CHANNELS[@]} -eq 0 ]; then - DOTNET_CHANNELS=('Current') + if [ -z "${DOTNET_CHANNELS:-}" ]; then + DOTNET_CHANNELS='Current' fi - if [[ "$DOTNET_RESET" == "1" ]]; then + if [ "$DOTNET_RESET" = '1' ]; then rm -rf "$DOTNET_INSTALL_DIR" fi @@ -65,14 +69,14 @@ __am-prompt-dotnet-install() { local DOTNET_URI='https://dot.net/v1/dotnet-install.sh' curl -fSsL $DOTNET_URI -o "$DOTNET_INSTALL_SH" 1>/dev/null 2>&1 - __am-prompt-safe-exec chmod +x "$DOTNET_INSTALL_SH" + __am_prompt_safe_exec chmod +x "$DOTNET_INSTALL_SH" - for DOTNET_VERSION in ${DOTNET_VERSIONS[@]}; do - __am-prompt-safe-exec "$DOTNET_INSTALL_SH" --version $DOTNET_VERSION + for DOTNET_VERSION in $DOTNET_VERSIONS; do + __am_prompt_safe_exec "$DOTNET_INSTALL_SH" __version $DOTNET_VERSION done - for DOTNET_CHANNEL in ${DOTNET_CHANNELS[@]}; do - __am-prompt-safe-exec "$DOTNET_INSTALL_SH" --channel $DOTNET_CHANNEL + for DOTNET_CHANNEL in $DOTNET_CHANNELS; do + __am_prompt_safe_exec "$DOTNET_INSTALL_SH" __channel $DOTNET_CHANNEL done mkdir -p /usr/local/share 1>/dev/null 2>&1 @@ -86,8 +90,8 @@ __am-prompt-dotnet-install() { export PATH="$HOME/.dotnet:$PATH" fi - echo "building dotnet cache... (this may take a few minutes)" + echo 'building dotnet cache... (this may take a few minutes)' dotnet help } -__am-prompt-dotnet-install $@ +__am_prompt_dotnet_install $@ diff --git a/src/scripts/edit-vars b/src/sh/scripts/edit-vars similarity index 56% rename from src/scripts/edit-vars rename to src/sh/scripts/edit-vars index 1a53c6e..8cebcd5 100755 --- a/src/scripts/edit-vars +++ b/src/sh/scripts/edit-vars @@ -1,14 +1,14 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-edit-vars() { +__am_prompt_edit_vars() { local VAR_PATH="$AM_PROMPT/user/variables" if [ ! -f "$VAR_PATH" ]; then - echo "#!/usr/bin/env bash" > "$VAR_PATH" + echo "#!/usr/bin/env sh" > "$VAR_PATH" echo >> "$VAR_PATH" fi ${EDITOR:-vi} "$VAR_PATH" } -__am-prompt-edit-vars +__am_prompt_edit_vars diff --git a/src/scripts/eval/set-brew-path b/src/sh/scripts/eval/set-brew-path similarity index 91% rename from src/scripts/eval/set-brew-path rename to src/sh/scripts/eval/set-brew-path index 381ca71..480600e 100755 --- a/src/scripts/eval/set-brew-path +++ b/src/sh/scripts/eval/set-brew-path @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh if [ -f "$HOME/.linuxbrew/bin/brew" ]; then eval $("$HOME/.linuxbrew/bin/brew" shellenv) diff --git a/src/scripts/eval/set-dotnet-path b/src/sh/scripts/eval/set-dotnet-path similarity index 95% rename from src/scripts/eval/set-dotnet-path rename to src/sh/scripts/eval/set-dotnet-path index 8eed14f..d3d4971 100755 --- a/src/scripts/eval/set-dotnet-path +++ b/src/sh/scripts/eval/set-dotnet-path @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh if [ -d "/usr/local/share/dotnet" ]; then export DOTNET_ROOT="/usr/local/share/dotnet" diff --git a/src/scripts/eval/set-go-path b/src/sh/scripts/eval/set-go-path similarity index 94% rename from src/scripts/eval/set-go-path rename to src/sh/scripts/eval/set-go-path index 3ef02de..6e50c7b 100755 --- a/src/scripts/eval/set-go-path +++ b/src/sh/scripts/eval/set-go-path @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # detect if go is installed and gopath is not already set if type go 1>/dev/null 2>&1; then @@ -12,6 +12,7 @@ fi # determine if go bin is specified if [ ! -z "${GOBIN}" ]; then + # add the go bin to the path export PATH=$PATH:$GOBIN fi diff --git a/src/sh/scripts/eval/set-nvm-path b/src/sh/scripts/eval/set-nvm-path new file mode 100755 index 0000000..2e44c1d --- /dev/null +++ b/src/sh/scripts/eval/set-nvm-path @@ -0,0 +1,12 @@ +#!/usr/bin/env sh + +NVM_PATH=$(brew --prefix nvm 2>/dev/null) + +if [ ! -d ${NVM_PATH} ]; then + NVM_PATH=$HOME/.nvm +fi + +if [ -f "$NVM_PATH/nvm.sh" ]; then + export NVM_DIR="${HOME}/.nvm" + . "$NVM_PATH/nvm.sh" +fi diff --git a/src/scripts/eval/set-python-path b/src/sh/scripts/eval/set-python-path similarity index 77% rename from src/scripts/eval/set-python-path rename to src/sh/scripts/eval/set-python-path index 35d1394..726414d 100755 --- a/src/scripts/eval/set-python-path +++ b/src/sh/scripts/eval/set-python-path @@ -1,8 +1,8 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh PYTHON=$(command -v python3 2>/dev/null || command -v python 2>/dev/null) -if [ -f $PYTHON ]; then +if ! test -z "${PYTHON:-}"; then USER_BASE_PATH=$($PYTHON -m site --user-base) export PATH=$PATH:$USER_BASE_PATH/bin fi diff --git a/src/sh/scripts/eval/source-os b/src/sh/scripts/eval/source-os new file mode 100755 index 0000000..7380024 --- /dev/null +++ b/src/sh/scripts/eval/source-os @@ -0,0 +1,28 @@ +#!/usr/bin/env sh + +__am_prompt_source_os() { + + local UNAME=$(uname | tr '[:upper:]' '[:lower:]') + local UNAME_PATH="$HOME/.am/prompt/sh/scripts/$UNAME" + + if [ -f /etc/os-release ]; then + . /etc/os-release + + local UNAME="$ID" + local UNAME_PATH="$HOME/.am/prompt/sh/scripts/$UNAME" + fi + + if [ -d "$UNAME_PATH" ]; then + export PATH="$UNAME_PATH:$PATH" + fi + + if [ -d "$UNAME_PATH/eval" ]; then + for EVAL_SCRIPT in $UNAME_PATH/eval/*; do + . "$EVAL_SCRIPT" + done + fi + + export AM_PROMPT_OS=$UNAME +} + +__am_prompt_source_os diff --git a/src/scripts/eval/update-prompt b/src/sh/scripts/eval/update-prompt similarity index 59% rename from src/scripts/eval/update-prompt rename to src/sh/scripts/eval/update-prompt index ba6b80c..a3b5a4f 100755 --- a/src/scripts/eval/update-prompt +++ b/src/sh/scripts/eval/update-prompt @@ -1,9 +1,7 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh if [ "${AM_PROMPT_UPDATE}" = "1" ]; then update-prompt --dry-run -fi - -if [ "${AM_PROMPT_UPDATE}" = "true" ]; then +elif [ "${AM_PROMPT_UPDATE}" = "true" ]; then update-prompt --dry-run fi diff --git a/src/scripts/fedora/minikube-install b/src/sh/scripts/fedora/minikube-install similarity index 92% rename from src/scripts/fedora/minikube-install rename to src/sh/scripts/fedora/minikube-install index 27fe264..ca864a1 100755 --- a/src/scripts/fedora/minikube-install +++ b/src/sh/scripts/fedora/minikube-install @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # install the hypervisor sudo dnf install @virtualization diff --git a/src/scripts/gcloud-install b/src/sh/scripts/gcloud-install similarity index 91% rename from src/scripts/gcloud-install rename to src/sh/scripts/gcloud-install index 43e28ea..0103b2c 100755 --- a/src/scripts/gcloud-install +++ b/src/sh/scripts/gcloud-install @@ -1,6 +1,6 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-gcloud-install() { +__am_prompt_gcloud_install() { local GCLOUD_PATH="$HOME/.gcloud" local PLATFORM='linux' @@ -33,7 +33,7 @@ __am-prompt-gcloud-install() { local GCLOUD_PATH_INC="$HOME/.gcloud/path.bash.inc" if [ -f "$GCLOUD_PATH_INC" ]; then - source "$GCLOUD_PATH_INC" + . "$GCLOUD_PATH_INC" fi fi @@ -43,4 +43,4 @@ __am-prompt-gcloud-install() { gcloud components update --quiet 2>&1 } -__am-prompt-gcloud-install +__am_prompt_gcloud_install diff --git a/src/sh/scripts/git-release b/src/sh/scripts/git-release new file mode 100644 index 0000000..c6136e7 --- /dev/null +++ b/src/sh/scripts/git-release @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +__am_prompt_git_release() { + + local ORG_NAME=${1:-'automotivemastermind'} + local REPO_NAME=${2:-'prompt'} + + local CURL_OPT='-s' + + if [ ! -z "${GH_TOKEN:-}" ]; then + CURL_OPT="$CURL_OPT -H 'Authorization: $GH_TOKEN'" + fi + + local RELEASE_URI=https://api.github.com/repos/$ORG_NAME/$REPO_NAME/releases/latest + local RELEASE=$(curl $CURL_OPT $RELEASE_URI | grep tag_name | head -n 1 | sed 's#.*\:.*"\(.*\).*",#\1#') + + if [ ! -z "${RELEASE:-}" ]; then + echo $RELEASE + return 0 + fi + + return 1 +} + +__am_prompt_git_release $@ diff --git a/src/scripts/git-sha b/src/sh/scripts/git-sha similarity index 91% rename from src/scripts/git-sha rename to src/sh/scripts/git-sha index 6f0d18f..393d2b7 100755 --- a/src/scripts/git-sha +++ b/src/sh/scripts/git-sha @@ -1,6 +1,7 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh + +__am_prompt_git_sha() { -__am-prompt-git-sha() { local ORG_NAME=$1 local REPO_NAME=$2 local BRANCH_NAME=$3 @@ -34,4 +35,4 @@ __am-prompt-git-sha() { return 1 } -__am-prompt-git-sha $@ +__am_prompt_git_sha $@ diff --git a/src/scripts/git-token b/src/sh/scripts/git-token similarity index 68% rename from src/scripts/git-token rename to src/sh/scripts/git-token index 69d5844..d715112 100755 --- a/src/scripts/git-token +++ b/src/sh/scripts/git-token @@ -1,6 +1,6 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-git-token() { +__am_prompt_git_token() { local GH_TOKEN=$1 if [ -z ${GH_TOKEN:-} ]; then @@ -10,4 +10,4 @@ __am-prompt-git-token() { fi } -__am-prompt-git-token $@ +__am_prompt_git_token $@ diff --git a/src/sh/scripts/kind-install b/src/sh/scripts/kind-install new file mode 100644 index 0000000..2e72f19 --- /dev/null +++ b/src/sh/scripts/kind-install @@ -0,0 +1,27 @@ +#!/usr/bin/env sh + +__am_kind_prompt_install() { + + # get the kind command + KIND=$(command -v kind 2>/dev/null) + + # determine if kind is already available + if ! test -z "${KIND:-}"; then + + # move on immediately + return 0 + fi + + # get the uname for the platform and the latest version of kind + local UNAME=$(uname | tr '[:upper:]' '[:lower:]') + local KIND_VERSION=$(git-release kubernetes-sigs kind) + local KIND_URL=https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-${UNAME}-amd64 + + # download the assembly to the bin + curl -Lso $LOCAL_PREFIX/kind $KIND_URL + + # make it executable + chmod +x $LOCAL_PREFIX/kind +} + +__am_kind_prompt_install diff --git a/src/sh/scripts/la b/src/sh/scripts/la new file mode 100755 index 0000000..43bbd47 --- /dev/null +++ b/src/sh/scripts/la @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +ls -la $@ diff --git a/src/sh/scripts/ll b/src/sh/scripts/ll new file mode 100755 index 0000000..70d8f79 --- /dev/null +++ b/src/sh/scripts/ll @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +ls -lh $@ diff --git a/src/sh/scripts/lla b/src/sh/scripts/lla new file mode 100755 index 0000000..7f8b351 --- /dev/null +++ b/src/sh/scripts/lla @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +ls -lha $@ diff --git a/src/sh/scripts/lsp b/src/sh/scripts/lsp new file mode 100755 index 0000000..1c3ba0d --- /dev/null +++ b/src/sh/scripts/lsp @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +ls -p $@ diff --git a/src/scripts/minikube-setup b/src/sh/scripts/minikube-setup similarity index 78% rename from src/scripts/minikube-setup rename to src/sh/scripts/minikube-setup index 802913f..cebda52 100755 --- a/src/scripts/minikube-setup +++ b/src/sh/scripts/minikube-setup @@ -1,13 +1,14 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh minikube config set cpus 4 minikube config set memory 4096 minikube config set bootstrapper kubeadm minikube config set kubernetes-version 1.15.5 -# enable the dashboard and heapter +# enable the dashboard and metrics server minikube config set dashboard true -minikube config set heapster true +minikube config set metrics-server true +minikube config set heapster false # make sure ingress is off minikube config set ingress false diff --git a/src/sh/scripts/minikube-start b/src/sh/scripts/minikube-start new file mode 100755 index 0000000..6df0b29 --- /dev/null +++ b/src/sh/scripts/minikube-start @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +# start minikube with rbac, psp, and token request projection +minikube start \ + --extra-config=apiserver.authorization-mode=RBAC \ + --extra-config=apiserver.enable-admission-plugins='PodSecurityPolicy' \ + --extra-config=apiserver.service-account-issuer=api \ + --extra-config=apiserver.service-account-signing-key-file=/var/lib/minikube/certs/sa.key \ + --extra-config=apiserver.service-account-key-file=/var/lib/minikube/certs/sa.pub \ + --extra-config=apiserver.service-account-api-audiences=api diff --git a/src/scripts/open-url b/src/sh/scripts/open-url similarity index 84% rename from src/scripts/open-url rename to src/sh/scripts/open-url index 533cef2..9cceec5 100755 --- a/src/scripts/open-url +++ b/src/sh/scripts/open-url @@ -1,6 +1,6 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-open-url() { +__am_prompt_open_url() { local url="$1" if [ -z ${1:-} ]; then @@ -19,4 +19,4 @@ __am-prompt-open-url() { return 1 } -__am-prompt-open-url $@ +__am_prompt_open_url $@ diff --git a/src/scripts/psp.yaml b/src/sh/scripts/psp.yaml similarity index 100% rename from src/scripts/psp.yaml rename to src/sh/scripts/psp.yaml diff --git a/src/sh/scripts/rd b/src/sh/scripts/rd new file mode 100755 index 0000000..264ad21 --- /dev/null +++ b/src/sh/scripts/rd @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +rm -r $@ diff --git a/src/scripts/remove-backup b/src/sh/scripts/remove-backup similarity index 63% rename from src/scripts/remove-backup rename to src/sh/scripts/remove-backup index 35f791a..49e60de 100755 --- a/src/scripts/remove-backup +++ b/src/sh/scripts/remove-backup @@ -1,9 +1,9 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-remove-backup() { +__am_prompt_remove_backup() { local BACKUP=$1 - if [ -z ${BACKUP:-} ]; then + if [ -z "${BACKUP:-}" ]; then BACKUP='prompt' fi @@ -13,4 +13,4 @@ __am-prompt-remove-backup() { rm -rf "$AM_HOME/backup/$BACKUP" 2>/dev/null } -__am-prompt-remove-backup $@ +__am_prompt_remove_backup $@ diff --git a/src/scripts/remove-bookmark b/src/sh/scripts/remove-bookmark similarity index 81% rename from src/scripts/remove-bookmark rename to src/sh/scripts/remove-bookmark index 9129551..a1358c4 100755 --- a/src/scripts/remove-bookmark +++ b/src/sh/scripts/remove-bookmark @@ -1,17 +1,17 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-remove-bookmark-usage() { +__am_prompt_remove_bookmark_usage() { echo 'remove-bookmark ' echo ' name : the name or path of your bookmark' } -__am-prompt-remove-bookmark() { +__am_prompt_remove_bookmark() { local BOOKMARK=$1 local USER_PATH="$AM_HOME/user" local ROW= if [ -z "${BOOKMARK:-}" ]; then - __am-prompt-remove-bookmark-usage + __am_prompt_remove_bookmark_usage return 1 fi @@ -38,7 +38,7 @@ __am-prompt-remove-bookmark() { grep -s -v $r "$USER_PATH/bookmarks" >> "$USER_PATH/bookmarks1" mv -f "$USER_PATH/bookmarks1" "$USER_PATH/bookmarks" - source "$USER_PATH/bookmarks" + . "$USER_PATH/bookmarks" } -__am-prompt-remove-bookmark $@ +__am_prompt_remove_bookmark $@ diff --git a/src/scripts/remove-var b/src/sh/scripts/remove-var similarity index 80% rename from src/scripts/remove-var rename to src/sh/scripts/remove-var index 16a0f6c..29de0b7 100755 --- a/src/scripts/remove-var +++ b/src/sh/scripts/remove-var @@ -1,22 +1,22 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh if [ ! -z "${AM_PROMPT_DEBUG:-}" ]; then echo 'remove-var' fi -__am-prompt-remove-var-usage() { +__am_prompt_remove_var_usage() { echo 'remove-var ' echo ' name : a name for your variable' } -__am-prompt-remove-var() { +__am_prompt_remove_var() { local VARIABLE=$1 local REMOVE= local USER_PATH="$AM_PROMPT/user" local VAR_PATH="$USER_PATH/variables" if [ -z "${VARIABLE:-}" ]; then - __am-prompt-remove-var-usage + __am_prompt_remove_var_usage return 1 fi @@ -34,7 +34,7 @@ __am-prompt-remove-var() { grep -s -v ^$VARIABLE "$VAR_PATH" >> "$USER_PATH/variables1" mv -f "$USER_PATH/variables1" "$USER_PATH/variables" - source "$USER_PATH/variables" + . "$USER_PATH/variables" } -__am-prompt-remove-var $@ +__am_prompt_remove_var $@ diff --git a/src/scripts/show-bookmarks b/src/sh/scripts/show-bookmarks similarity index 75% rename from src/scripts/show-bookmarks rename to src/sh/scripts/show-bookmarks index 220ca72..2b889ff 100755 --- a/src/scripts/show-bookmarks +++ b/src/sh/scripts/show-bookmarks @@ -1,6 +1,6 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-show-bookmarks() { +__am_prompt_show_bookmarks() { local BOOKMARK_PATH="$HOME/.am/prompt/user/bookmarks" if [ ! -f $BOOKMARK_PATH ]; then @@ -12,4 +12,4 @@ __am-prompt-show-bookmarks() { cat $BOOKMARK_PATH } -__am-prompt-show-bookmarks +__am_prompt_show_bookmarks diff --git a/src/scripts/show-colors b/src/sh/scripts/show-colors similarity index 65% rename from src/scripts/show-colors rename to src/sh/scripts/show-colors index ba49af9..4f621a5 100755 --- a/src/scripts/show-colors +++ b/src/sh/scripts/show-colors @@ -1,19 +1,19 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh echo for color in $(env | awk '/^CLR_BRIGHT/' | cut -d= -f1 | sort); do - echo -e "${!color}\$$color${CLR_CLEAR}" + echo "${!color}\$$color${CLR_CLEAR}" done echo for color in $(env | awk '/^CLR_/' | awk '!/^CLR_BRIGHT/' | awk '!/_PROMPT/' | cut -d= -f1 | sort); do - echo -e "${!color}\$$color${CLR_CLEAR}" + echo "${!color}\$$color${CLR_CLEAR}" done echo for color in $(env | awk '/^CLR/' | awk '/_PROMPT/' | cut -d= -f1 | sort); do - echo -e "${!color}\$$color${CLR_CLEAR}" + echo "${!color}\$$color${CLR_CLEAR}" done diff --git a/src/scripts/show-profile b/src/sh/scripts/show-profile similarity index 85% rename from src/scripts/show-profile rename to src/sh/scripts/show-profile index 8cca3e3..f1b40c1 100755 --- a/src/scripts/show-profile +++ b/src/sh/scripts/show-profile @@ -1,3 +1,3 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh history | awk "{print \$2}" | awk "BEGIN{FS=\"|\"}{print \$1}" | sort | uniq -c | sort -n | tail -n 20 | sort -nr diff --git a/src/scripts/show-vars b/src/sh/scripts/show-vars similarity index 76% rename from src/scripts/show-vars rename to src/sh/scripts/show-vars index 8a8fac8..5469fec 100755 --- a/src/scripts/show-vars +++ b/src/sh/scripts/show-vars @@ -1,6 +1,6 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -__am-prompt-show-vars() { +__am_prompt_show_vars() { local VAR_PATH="$HOME/.am/prompt/user/variables.sh" if [ ! -f $VAR_PATH ]; then @@ -12,4 +12,4 @@ __am-prompt-show-vars() { cat $VAR_PATH } -__am-prompt-show-vars +__am_prompt_show_vars diff --git a/src/scripts/ubuntu/minikube-install b/src/sh/scripts/ubuntu/minikube-install similarity index 90% rename from src/scripts/ubuntu/minikube-install rename to src/sh/scripts/ubuntu/minikube-install index 730ce23..20108d6 100755 --- a/src/scripts/ubuntu/minikube-install +++ b/src/sh/scripts/ubuntu/minikube-install @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # install the hypervisor sudo apt-get install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils diff --git a/src/sh/scripts/update-prompt b/src/sh/scripts/update-prompt new file mode 100755 index 0000000..d07d3a4 --- /dev/null +++ b/src/sh/scripts/update-prompt @@ -0,0 +1,102 @@ +#!/usr/bin/env sh + +set -e + +__am_prompt_update() +{ + local CLR_FAIL=${CLR_FAIL:-"\033[1;31m"} # BRIGHT RED + local CLR_SUCCESS=${CLR_SUCCESS:-"\033[1;32m"} # BRIGHT GREEN + local CLR_WARN=${CLR_WARN:-"\033[1;33m"} # BRIGHT YELLOW + local CLR_CLEAR=${CLR_CLEAR:-"\033[0m"} # DEFAULT COLOR + + local GH_TOKEN=${GH_TOKEN:-} + local PROMPT_TOKEN=${PROMPT_TOKEN:-} + local PROMPT_TOKEN=${PROMPT_TOKEN:-$GH_TOKEN} + local PROMPT_CURL_OPT=${PROMPT_CURL_OPT:-'-s'} + local PROMPT_COMMIT_REF=${PROMPT_COMMIT_REF:-"master"} + local PROMPT_SHELL=${PROMPT_SHELL:-"bash"} + local PROMPT_DRY_RUN=${PROMPT_DRY_RUN:-} + + while :; do + case $1 in + -t|--token) + PROMPT_TOKEN=$2 + shift + ;; + -v|--version) + PROMPT_COMMIT_REF=$2 + shift + ;; + -dr|--dry-run) + PROMPT_DRY_RUN=1 + ;; + -f|--force) + rm -rf "$HOME/.am/prompt/.sha" 1>/dev/null 2>&1 + ;; + --debug) + set -x + ;; + ?*) + PROMPT_SHELL=$1 + ;; + *) + break + ;; + esac + shift + done + + if [ ! -z "${PROMPT_TOKEN:-}" ]; then + PROMPT_CURL_OPT='$PROMPT_CURL_OPT -H "Authorization: token $PROMPT_TOKEN"' + fi + + local PROMPT_SHA_URI="https://api.github.com/repos/automotiveMastermind/prompt/commits/$PROMPT_COMMIT_REF" + local PROMPT_SHA=$(curl $PROMPT_CURL_OPT $PROMPT_SHA_URI | grep sha | head -n 1 | sed 's#.*\:.*"\(.*\).*",#\1#') + + # detect if sha could be located + if [ -z ${PROMPT_SHA:-} ]; then + echo "${CLR_FAIL}prompt: cannot retrieve SHA of latest version. Are you connected to the internet?${CLR_CLEAR}" + return 1 + fi + + local PROMPT_SHA_PATH=$HOME/.am/prompt/.sha + + # detect if sha file exists + if [ -f "$PROMPT_SHA_PATH" ]; then + + # get the value of the sha file + PROMPT_CURRENT_SHA=$(cat "$PROMPT_SHA_PATH") + + # print latest version already installed + if [ "${PROMPT_SHA}" = "${PROMPT_CURRENT_SHA}" ]; then + echo "${CLR_SUCCESS}prompt: latest version already installed: ${PROMPT_SHA}.${CLR_CLEAR}" + exit 0 + fi + fi + + if [ ! -z "${PROMPT_DRY_RUN:-}" ]; then + echo "${CLR_WARN}prompt: a new version of prompt is available: ${PROMPT_SHA}." + echo " - run the update-prompt command line tool to upgrade${CLR_CLEAR}" + return 0 + fi + + remove-backup + + local PROMPT_CHANGELOG_URI="https://github.com/automotivemastermind/prompt/blob/$PROMPT_COMMIT_REF/CHANGELOG.md" + local PROMPT_INSTALL_URI="https://github.com/automotiveMastermind/prompt/archive/$PROMPT_COMMIT_REF.tar.gz" + local PROMPT_INTALL_TEMP=$(mktemp -d) + local PROMPT_EXTRACT_TEMP="$PROMPT_INTALL_TEMP/extract" + + pushd $PROMPT_INTALL_TEMP 1>/dev/null + curl -skL $PROMPT_INSTALL_URI | tar zx + pushd prompt-master 1>/dev/null + ./install.sh $PROMPT_SHELL + popd 1>/dev/null + popd 1>/dev/null + + rm -rf $PROMPT_INTALL_TEMP 1>/dev/null + + open-url $CHANGELOG_URI 1>/dev/null +} + +__am_prompt_update $@ diff --git a/src/scripts/update-sln b/src/sh/scripts/update-sln similarity index 98% rename from src/scripts/update-sln rename to src/sh/scripts/update-sln index a74670f..2ab6786 100755 --- a/src/scripts/update-sln +++ b/src/sh/scripts/update-sln @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh __contains() { for item in "${@:2}"; do [[ "$item" == "$1" ]] && return 0; done; return 1; } diff --git a/src/sh/scripts/use-shell b/src/sh/scripts/use-shell new file mode 100755 index 0000000..8507dcc --- /dev/null +++ b/src/sh/scripts/use-shell @@ -0,0 +1,57 @@ +#! /usr/bin/env sh + +__am_prompt_use_shell() { + + local PROMPT_SHELL=$1 + local ECHO=${ECHO:-"echo"} + + if [ -z "${PROMPT_SHELL:-}" ]; then + echo "${CLR_FAIL}You must specify a shell to use, either bash or zsh.${CLR_CLEAR}" + exit 1 + fi + + if type brew 1>/dev/null 2>&1; then + local LOCAL_PREFIX=$(brew --prefix) + 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 PROMPT_SHELL_PATH="$LOCAL_PREFIX/bin/$PROMPT_SHELL" + local UNAME=$(uname | tr '[:upper:]' '[:lower:]') + local UNAME_INSTALL="$UNAME.sh" + + if [ -f /etc/os-release ]; then + . /etc/os-release + + local UNAME_INSTALL="$ID.sh" + fi + + if [ -f "$AM_PROMPT/$PROMPT_SHELL/install/$UNAME_INSTALL" ]; then + . "$AM_PROMPT/$PROMPT_SHELL/install/$UNAME_INSTALL" + fi + + if ! grep "$PROMPT_SHELL_PATH" /etc/shells 1>/dev/null 2>&1; then + echo "${CLR_SUCCESS}adding updated $PROMPT_SHELL to shells...${CLR_CLEAR}" + sudo sh -c "echo $PROMPT_SHELL_PATH >> /etc/shells" + fi + + if [ "$SHELL" != "$PROMPT_SHELL_PATH" ]; then + echo "${CLR_SUCCESS}setting updated $PROMPT_SHELL to default shell for user...${CLR_CLEAR}" + sudo chsh -s $PROMPT_SHELL_PATH $USER + + # set the default shell for the current session + export SHELL="$PROMPT_SHELL_PATH" + fi + + echo "${CLR_SUCCESS}" + echo "##############################################################################" + echo "##############################################################################" + echo " PLEASE RUN: exec -l \$SHELL # ($SHELL)" + echo "##############################################################################" + echo "##############################################################################" + echo "${CLR_CLEAR}" +} + +__am_prompt_use_shell $@ diff --git a/src/themes/terminal/Monokai.terminal b/src/themes/terminal/Monokai.terminal old mode 100644 new mode 100755 diff --git a/src/themes/terminal/dark-mode.terminal b/src/themes/terminal/dark-mode.terminal new file mode 100644 index 0000000..0cf05fc --- /dev/null +++ b/src/themes/terminal/dark-mode.terminal @@ -0,0 +1,282 @@ + + + + + ANSIBlackColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGmCwwXHR4lVSRudWxs1Q0ODxAR + EhMUFRZcTlNDb21wb25lbnRzVU5TUkdCXE5TQ29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29s + b3JTcGFjZVYkY2xhc3NPECwwLjAwMzkyMTU2ODYyNyAwLjAyMzUyOTQxMTc2IDAuMDU0 + OTAxOTYwNzggMU8QLDYuODgxMTgwMTYxZS0wNSAwLjAyOTI1MzQzODEyIDAuMDUwNjYw + NzIxOTYAEAGAAoAF0xgRGRobHFVOU0lDQ1lOU1NwYWNlSUSAA4AEEAxPEQIkAAACJGFw + cGwEAAAAbW50clJHQiBYWVogB+EABwAHAA0AFgAgYWNzcEFQUEwAAAAAQVBQTAAAAAAA + AAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1hcHBsyhqVgiV/EE04mRPV0eoVggAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKZGVzYwAAAPwAAABlY3BydAAAAWQAAAAjd3Rw + dAAAAYgAAAAUclhZWgAAAZwAAAAUZ1hZWgAAAbAAAAAUYlhZWgAAAcQAAAAUclRSQwAA + AdgAAAAgY2hhZAAAAfgAAAAsYlRSQwAAAdgAAAAgZ1RSQwAAAdgAAAAgZGVzYwAAAAAA + AAALRGlzcGxheSBQMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXh0AAAA + AENvcHlyaWdodCBBcHBsZSBJbmMuLCAyMDE3AABYWVogAAAAAAAA81EAAQAAAAEWzFhZ + WiAAAAAAAACD3wAAPb////+7WFlaIAAAAAAAAEq/AACxNwAACrlYWVogAAAAAAAAKDgA + ABELAADIuXBhcmEAAAAAAAMAAAACZmYAAPKnAAANWQAAE9AAAApbc2YzMgAAAAAAAQxC + AAAF3v//8yYAAAeTAAD9kP//+6L///2jAAAD3AAAwG7SHyAhIlokY2xhc3NuYW1lWCRj + bGFzc2VzXE5TQ29sb3JTcGFjZaIjJFxOU0NvbG9yU3BhY2VYTlNPYmplY3TSHyAmJ1dO + U0NvbG9yoiYkAAgAEQAaACQAKQAyADcASQBMAFEAUwBaAGAAawB4AH4AiwCgAKcA1gEF + AQcBCQELARIBGAEiASQBJgEoA1ADVQNgA2kDdgN5A4YDjwOUA5wAAAAAAAACAQAAAAAA + AAAoAAAAAAAAAAAAAAAAAAADnw== + + ANSIBlueColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC4zMjU0OTAxOTYxIDAuNzQxMTc2NDcw + NiAwLjk4MDM5MjE1NjkAEAGAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv + cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA + AAAZAAAAAAAAAAAAAAAAAAAA2Q== + + ANSIBrightBlackColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC40MDc4NDMxMzczIDAuNDA3ODQzMTM3 + MyAwLjQwNzg0MzEzNzMAEAGAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv + cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA + AAAZAAAAAAAAAAAAAAAAAAAA2Q== + + ANSIBrightBlueColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAcMC4zNDkwMTk2MDc4IDAuNzYwNzg0MzEz + NyAxABABgALSFBUWF1okY2xhc3NuYW1lWCRjbGFzc2VzV05TQ29sb3KiFhhYTlNPYmpl + Y3QIERokKTI3SUxRU1ddZGp3fp2foaaxusLFAAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAA + AAAAAAAAAM4= + + ANSIBrightCyanColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC41ODQzMTM3MjU1IDAuOTAxOTYwNzg0 + MyAwLjc5NjA3ODQzMTQAEAGAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv + cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA + AAAZAAAAAAAAAAAAAAAAAAAA2Q== + + ANSIBrightGreenColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC43NjA3ODQzMTM3IDAuODUwOTgwMzky + MiAwLjI5ODAzOTIxNTcAEAKAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv + cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA + AAAZAAAAAAAAAAAAAAAAAAAA2Q== + + ANSIBrightMagentaColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxATMSAwLjkzMzMzMzMzMzMgMC42ABABgALS + FBUWF1okY2xhc3NuYW1lWCRjbGFzc2VzV05TQ29sb3KiFhhYTlNPYmplY3QIERokKTI3 + SUxRU1ddZGp3fpSWmJ2osbm8AAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAAAAAAAAAAAMU= + + ANSIBrightRedColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC45NDExNzY0NzA2IDAuNDQzMTM3MjU0 + OSAwLjQ3MDU4ODIzNTMAEAKAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv + cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA + AAAZAAAAAAAAAAAAAAAAAAAA2Q== + + ANSIBrightWhiteColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzRjEgMSAxABACgALSFBUWF1okY2xhc3NuYW1l + WCRjbGFzc2VzV05TQ29sb3KiFhhYTlNPYmplY3QIERokKTI3SUxRU1ddZGp3foWHiY6Z + oqqtAAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAAAAAAAAAAALY= + + ANSIBrightYellowColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAcMSAwLjcwNTg4MjM1MjkgMC4zMjk0MTE3 + NjQ3ABABgALSFBUWF1okY2xhc3NuYW1lWCRjbGFzc2VzV05TQ29sb3KiFhhYTlNPYmpl + Y3QIERokKTI3SUxRU1ddZGp3fp2foaaxusLFAAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAA + AAAAAAAAAM4= + + ANSICyanColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC41NjQ3MDU4ODI0IDAuODgyMzUyOTQx + MiAwLjc3NjQ3MDU4ODIAEAGAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv + cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA + AAAZAAAAAAAAAAAAAAAAAAAA2Q== + + ANSIGreenColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAmMC41Njg2Mjc0NTEgMC43MDE5NjA3ODQz + IDAuMzg0MzEzNzI1NQAQAYAC0hQVFhdaJGNsYXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9y + ohYYWE5TT2JqZWN0CBEaJCkyN0lMUVNXXWRqd36nqauwu8TMzwAAAAAAAAEBAAAAAAAA + ABkAAAAAAAAAAAAAAAAAAADY + + ANSIMagentaColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC45ODAzOTIxNTY5IDAuOTEzNzI1NDkw + MiAwLjU4MDM5MjE1NjkAEAGAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv + cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA + AAAZAAAAAAAAAAAAAAAAAAAA2Q== + + ANSIRedColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC45MTc2NDcwNTg4IDAuNDIzNTI5NDEx + OCAwLjQ1MDk4MDM5MjIAEAGAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv + cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA + AAAZAAAAAAAAAAAAAAAAAAAA2Q== + + ANSIWhiteColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC43ODAzOTIxNTY5IDAuNzgwMzkyMTU2 + OSAwLjc4MDM5MjE1NjkAEAKAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv + cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA + AAAZAAAAAAAAAAAAAAAAAAAA2Q== + + ANSIYellowColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC45NzY0NzA1ODgyIDAuNjg2Mjc0NTA5 + OCAwLjMwOTgwMzkyMTYAEAGAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv + cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA + AAAZAAAAAAAAAAAAAAAAAAAA2Q== + + BackgroundColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAvMC4wMzkyMTU2ODYyNyAwLjA1NDkwMTk2 + MDc4IDAuMDc4NDMxMzcyNTUgMC44NQAQAoAC0hQVFhdaJGNsYXNzbmFtZVgkY2xhc3Nl + c1dOU0NvbG9yohYYWE5TT2JqZWN0CBEaJCkyN0lMUVNXXWRqd36wsrS5xM3V2AAAAAAA + AAEBAAAAAAAAABkAAAAAAAAAAAAAAAAAAADh + + CursorBlink + + CursorColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzRjEgMSAxABABgALSFBUWF1okY2xhc3NuYW1l + WCRjbGFzc2VzV05TQ29sb3KiFhhYTlNPYmplY3QIERokKTI3SUxRU1ddZGp3foWHiY6Z + oqqtAAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAAAAAAAAAAALY= + + CursorType + 2 + Font + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGkCwwVFlUkbnVsbNQNDg8QERIT + FFZOU1NpemVYTlNmRmxhZ3NWTlNOYW1lViRjbGFzcyNAKAAAAAAAABAQgAKAA18QEEZp + cmFDb2RlLVJlZ3VsYXLSFxgZGlokY2xhc3NuYW1lWCRjbGFzc2VzVk5TRm9udKIZG1hO + U09iamVjdAgRGiQpMjdJTFFTWF5nbnd+hY6QkpSnrLfAx8oAAAAAAAABAQAAAAAAAAAc + AAAAAAAAAAAAAAAAAAAA0w== + + FontAntialias + + Linewrap + + ProfileCurrentVersion + 2.0699999999999998 + SelectionColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC4wODYyNzQ1MDk4IDAuMTIxNTY4NjI3 + NSAwLjE2NDcwNTg4MjQAEAGAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv + cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA + AAAZAAAAAAAAAAAAAAAAAAAA2Q== + + ShowActiveProcessInTitle + + ShowCommandKeyInTitle + + ShowComponentsWhenTabHasCustomTitle + + ShowDimensionsInTitle + + ShowRepresentedURLPathInTitle + + ShowShellCommandInTitle + + ShowTTYNameInTitle + + ShowWindowSettingsNameInTitle + + TextBoldColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxAREldO + U1doaXRlXE5TQ29sb3JTcGFjZVYkY2xhc3NCMQAQA4AC0hQVFhdaJGNsYXNzbmFtZVgk + Y2xhc3Nlc1dOU0NvbG9yohYYWE5TT2JqZWN0CBEaJCkyN0lMUVNXXWRseYCDhYeMl6Co + qwAAAAAAAAEBAAAAAAAAABkAAAAAAAAAAAAAAAAAAAC0 + + TextColor + + YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS + AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO + U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC43MDE5NjA3ODQzIDAuNjk0MTE3NjQ3 + MSAwLjY3ODQzMTM3MjUAEAGAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv + cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA + AAAZAAAAAAAAAAAAAAAAAAAA2Q== + + UseBoldFonts + + UseBrightBold + + WindowTitle + Terminal + columnCount + 150 + name + Dark Mode + noWarnProcesses + + + ProcessName + rlogin + + + ProcessName + telnet + + + ProcessName + ssh + + + ProcessName + slogin + + + ProcessName + screen + + + ProcessName + tmux + + + rowCount + 50 + type + Window Settings + + diff --git a/src/user/bashrc b/src/user/bashrc old mode 100644 new mode 100755 index 20d602b..f1f641a --- a/src/user/bashrc +++ b/src/user/bashrc @@ -1,2 +1 @@ #!/usr/bin/env bash - diff --git a/src/user/variables b/src/user/variables old mode 100644 new mode 100755 index 6d3c6cb..408adf9 --- a/src/user/variables +++ b/src/user/variables @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -AM_PROMPT_MARKER="==>" -AM_PROMPT_UPDATE=1 \ No newline at end of file +AM_PROMPT_MARKER=${AM_PROMPT_MARKER:-'==>'} +AM_PROMPT_UPDATE=${AM_PROMPT_UPDATE:-1} diff --git a/src/user/zshrc b/src/user/zshrc new file mode 100755 index 0000000..8441a36 --- /dev/null +++ b/src/user/zshrc @@ -0,0 +1 @@ +#!/usr/bin/env zsh diff --git a/src/zsh/install/centos.sh b/src/zsh/install/centos.sh new file mode 100755 index 0000000..fc812d2 --- /dev/null +++ b/src/zsh/install/centos.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +. "$AM_PROMPT/zsh/install/linux.sh" diff --git a/src/zsh/install/darwin.sh b/src/zsh/install/darwin.sh new file mode 100755 index 0000000..d108f88 --- /dev/null +++ b/src/zsh/install/darwin.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +__am_prompt_install_darwin() { + local BREWS='zsh' + + set +e + + for pkg in $BREWS; do + if brew list -1 | grep -q "^${pkg}\$"; then + $ECHO "${CLR_SUCCESS}upgrading: $pkg...${CLR_CLEAR}" + brew upgrade $pkg 2>/dev/null + brew link --overwrite $pkg 2>/dev/null + else + $ECHO "${CLR_SUCCESS}installing: $pkg...${CLR_CLEAR}" + brew install $pkg + fi + done +} + +__am_prompt_install_darwin diff --git a/src/zsh/install/debian.sh b/src/zsh/install/debian.sh new file mode 100755 index 0000000..fc812d2 --- /dev/null +++ b/src/zsh/install/debian.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +. "$AM_PROMPT/zsh/install/linux.sh" diff --git a/src/zsh/install/fedora.sh b/src/zsh/install/fedora.sh new file mode 100755 index 0000000..5605a28 --- /dev/null +++ b/src/zsh/install/fedora.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +. "$AM_PROMPT/zsh/install/centos.sh" diff --git a/src/zsh/install/linux.sh b/src/zsh/install/linux.sh new file mode 100755 index 0000000..51d6c76 --- /dev/null +++ b/src/zsh/install/linux.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +__am_prompt_install_linux() { + local BREWS='zsh' + + set +e + + for pkg in $BREWS; do + if brew list -1 | grep -q "^${pkg}\$"; then + $ECHO "${CLR_SUCCESS}upgrading: $pkg...${CLR_CLEAR}" + brew upgrade $pkg 2>/dev/null + brew link --overwrite $pkg 2>/dev/null + else + $ECHO "${CLR_SUCCESS}installing: $pkg...${CLR_CLEAR}" + brew install $pkg + fi + done +} + +__am_prompt_install_linux diff --git a/src/zsh/install/linuxmint.sh b/src/zsh/install/linuxmint.sh new file mode 100755 index 0000000..fc812d2 --- /dev/null +++ b/src/zsh/install/linuxmint.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +. "$AM_PROMPT/zsh/install/linux.sh" diff --git a/src/zsh/install/ubuntu.sh b/src/zsh/install/ubuntu.sh new file mode 100755 index 0000000..33986eb --- /dev/null +++ b/src/zsh/install/ubuntu.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +. "$AM_PROMPT/zsh/install/debian.sh" diff --git a/src/zsh/scripts/darwin/eval/docker-completion b/src/zsh/scripts/darwin/eval/docker-completion new file mode 100755 index 0000000..ae2cbb4 --- /dev/null +++ b/src/zsh/scripts/darwin/eval/docker-completion @@ -0,0 +1,35 @@ +#!/usr/bin/env sh + +if [ -d /Applications/Docker.app/Contents/Resources/etc ]; then + + local DOCKER_PATH=/Applications/Docker.app/Contents/Resources/etc + +elif [ -d "$HOME/Applications/Docker.app/Contents/Resources/etc" ]; then + + local DOCKER_PATH="$HOME/Applications/Docker.app/Contents/Resources/etc" +fi + +if [ ! -z "${DOCKER_PATH:-}" ]; then + + # enable short option stacking for docker + zstyle ':completion:*:*:docker:*' option-stacking yes + zstyle ':completion:*:*:docker-*:*' option-stacking yes + + # add completion for docker + if [ ! -f "${ZSH_COMPLETION_DIR}/_docker" ]; then + ln -s $DOCKER_PATH/docker.zsh-completion $ZSH_COMPLETION_DIR/_docker + . $ZSH_COMPLETION_DIR/_docker + fi + + # add completion for docker-machine + if [ ! -f "${ZSH_COMPLETION_DIR}/_docker-machine" ]; then + ln -s $DOCKER_PATH/docker-machine.zsh-completion $ZSH_COMPLETION_DIR/_docker-machine + . $ZSH_COMPLETION_DIR/_docker-machine + fi + + # add completion for docker-compose + if [ ! -f "${ZSH_COMPLETION_DIR}/_docker-compose" ]; then + ln -s $DOCKER_PATH/docker-compose.zsh-completion $ZSH_COMPLETION_DIR/_docker-compose + . $ZSH_COMPLETION_DIR/_docker-compose + fi +fi diff --git a/src/zsh/scripts/edit-zshrc b/src/zsh/scripts/edit-zshrc new file mode 100755 index 0000000..6ae8c2b --- /dev/null +++ b/src/zsh/scripts/edit-zshrc @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +__am_prompt_edit_zshrc() { + + local ZSHRC_PATH="$AM_PROMPT/user/zshrc" + + if [ ! -f "$ZSHRC_PATH" ]; then + echo "#!/usr/bin/env zsh" > "$ZSHRC_PATH" + echo >> "$ZSHRC_PATH" + fi + + ${EDITOR:-vi} "$ZSHRC_PATH" +} + +__am_prompt_edit_zshrc diff --git a/src/zsh/scripts/eval/set-completion b/src/zsh/scripts/eval/set-completion new file mode 100755 index 0000000..6b9e5d0 --- /dev/null +++ b/src/zsh/scripts/eval/set-completion @@ -0,0 +1,53 @@ +#!/usr/bin/env zsh + +# use case sensitive match followed by case-insensitive match +zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' + +if type gulp 1>/dev/null 2>&1; then + . <(gulp --completion=zsh) +fi + +if type grunt 1>/dev/null 2>&1; then + . <(grunt --completion=zsh) +fi + +if type kubectl 1>/dev/null 2>&1; then + . <(kubectl completion zsh) +fi + +if type helm 1>/dev/null 2>&1; then + . <(helm completion zsh) +fi + +if type minikube 1>/dev/null 2>&1; then + . <(minikube completion zsh) +fi + +if type nvm 1>/dev/null 2>&1; then + . <(npm completion) +fi + +__am_prompt_dotnet_zsh_complete() +{ + local COMPLETIONS=("$(dotnet complete "$WORDS")") + + reply=( "${(ps:\n:)COMPLETIONS}" ) +} + +if type dotnet 1>/dev/null 2>&1; then + compctl -K __am_prompt_dotnet_zsh_complete dotnet +fi + +# determine if completions exist +if [ ! -d "$AM_PROMPT/zsh/completions" ]; then + + # move on immediately + return +fi + +# iterate over each completion +for AM_COMPLETION in $AM_PROMPT/zsh/completions/*; do + + # source the completion + . "$AM_COMPLETION" +done diff --git a/src/zsh/scripts/eval/set-gcloud-path b/src/zsh/scripts/eval/set-gcloud-path new file mode 100755 index 0000000..7f18c3c --- /dev/null +++ b/src/zsh/scripts/eval/set-gcloud-path @@ -0,0 +1,54 @@ +#!/usr/bin/env zsh + +__am_prompt_set_gcloud_path() { + + # detect gcloud + if ! test type gcloud 1>/dev/null 2>&1; then + + # attempt to discover the path + if [ ! -f "$HOME/.gcloud/bin/gcloud" ]; then + + # no gcloud installed + return + fi + + # add gcloud to the path + export PATH="$HOME/.gcloud/bin":$PATH + fi + + local GCLOUD_CMD=$(command -v gcloud) + local GCLOUD_DIR=$(dirname "$GCLOUD_CMD") + + local GCLOUD_PATH_INC="$GCLOUD_DIR/path.zsh.inc" + local GCLOUD_COMPLETION_INC="$GCLOUD_DIR/completion.zsh.inc" + + # detect the gcloud path + if [ ! -f "$ZSH_COMPLETION_DIR/_gcloud-path" ]; then + + # detect gcloud path completion + if [ -f "$GCLOUD_PATH_INC" ]; then + + # link the gcloud path to the completion dir + ln -s $GCLOUD_PATH_INC "$ZSH_COMPLETION_DIR/_gcloud-path" + + # source the path + . "$ZSH_COMPLETION_DIR/_gcloud-path" + fi + fi + + # detect the gcloud completion path + if [ ! -f "$ZSH_COMPLETION_DIR/_gcloud-completion" ]; then + + # detect gcloud command completion + if [ -f "$GCLOUD_COMPLETION_INC" ]; then + + # link the gcloud completion to the completion dir + ln -s $GCLOUD_COMPLETION_INC "$ZSH_COMPLETION_DIR/_gcloud-completion" + + # source the path + . "$ZSH_COMPLETION_DIR/_gcloud-completion" + fi + fi +} + +__am_prompt_set_gcloud_path diff --git a/src/zsh/scripts/eval/set-prompt b/src/zsh/scripts/eval/set-prompt new file mode 100755 index 0000000..adac469 --- /dev/null +++ b/src/zsh/scripts/eval/set-prompt @@ -0,0 +1,42 @@ +#!/usr/bin/env zsh + +__am_prompt_emit_prompt_arrow() { + + # set the default color + local CLR_PROMPT=$CLR_USER_PROMPT + + # set color for staff user (administrator) + if [ ! -z "$(command id -Gn 2>/dev/null | grep -s -o admin)" ]; then + CLR_PROMPT=$CLR_STAFF_PROMPT + fi + + # set color for root user + if [ $(id -u) = 0 ]; then + CLR_PROMPT=$CLR_ROOT_PROMPT + fi + + # set the color for an ssh session + if [ ! -z "${SSH_CONNECTION:-}" ]; then + CLR_PROMPT=$CLR_SSH_PROMPT + + # emit the prompt using the correct color + export AM_PROMPT_ARROW="${CLR_PROMPT} (ssh) ${AM_PROMPT_MARKER:-==>} ${CLR_CLEAR_PROMPT}" + else + # emit the prompt using the correct color + export AM_PROMPT_ARROW="${CLR_PROMPT} ${AM_PROMPT_MARKER:-==>} ${CLR_CLEAR_PROMPT}" + fi +} + +__am_prompt_set_prompt() { + # set the window title + echo -ne "\033]0;${USER}@${HOSTNAME%%.*} ${PWD}\007" + + local NEWLINE=$'\n' + __posh_git_ps1 "${NEWLINE}%n@%m : %~${NEWLINE}" " $AM_PROMPT_ARROW" +} + +# set up the arrow +__am_prompt_emit_prompt_arrow + +# set the prompt command +precmd_functions=(__am_prompt_set_prompt) diff --git a/src/zsh/scripts/eval/source-os b/src/zsh/scripts/eval/source-os new file mode 100755 index 0000000..1e0d9c9 --- /dev/null +++ b/src/zsh/scripts/eval/source-os @@ -0,0 +1,28 @@ +#!/usr/bin/env zsh + +__am_prompt_source_os() { + + local UNAME=$(uname | tr '[:upper:]' '[:lower:]') + local UNAME_PATH="$HOME/.am/prompt/zsh/scripts/$UNAME" + + if [ -f /etc/os-release ]; then + . /etc/os-release + + local UNAME="$ID" + local UNAME_PATH="$HOME/.am/prompt/zsh/scripts/$UNAME" + fi + + if [ -d "$UNAME_PATH" ]; then + export PATH="$UNAME_PATH:$PATH" + fi + + if [ -d "$UNAME_PATH/eval" ]; then + for EVAL_SCRIPT in $UNAME_PATH/eval/*; do + . "$EVAL_SCRIPT" + done + fi + + export AM_PROMPT_OS=$UNAME +} + +__am_prompt_source_os diff --git a/src/zsh/zshrc b/src/zsh/zshrc new file mode 100644 index 0000000..547a665 --- /dev/null +++ b/src/zsh/zshrc @@ -0,0 +1,46 @@ +#!/usr/bin/env zsh + +# determine if this is a tty +if [ -t 1 ]; then + + # update colors for prompt + export CLR_ROOT_PROMPT='%B%F{red}' # COLOR OF THE PROMPT FOR ROOT + export CLR_STAFF_PROMPT='%B%F{green}' # COLOR OF THE PROMPT FOR STAFF + export CLR_USER_PROMPT='%B%F{red}' # COLOR OF THE PROMPT FOR USERS + export CLR_SSH_PROMPT='%B%F{magenta}' # COLOR OF THE PROMPT FOR SSH + export CLR_CLEAR_PROMPT='%f%b' # CLEAR THE COLOR FOR PROMPT +fi + +# shell options +setopt CDABLE_VARS + +# rebuild completion +rm -rf $HOME/.zcompdump +autoload -U compinit +compinit + +# get zsh completion dir +export ZSH_COMPLETION_DIR="$AM_PROMPT/user/zsh/completions" + +# determine if the completion dir does not exist +if [ ! -d "${ZSH_COMPLETION_DIR}" ]; then + + # create the completion dir + mkdir -p "$ZSH_COMPLETION_DIR" 1>/dev/null 2>&1 +fi + +# add completion dir to fpath +fpath=($ZSH_COMPLETION_DIR $fpath) + +# add scripts to path +export PATH="$AM_PROMPT/zsh/scripts:$PATH" + +# evaluate eval scripts +for EVAL_SCRIPT in $AM_PROMPT/zsh/scripts/eval/*; do + . "$EVAL_SCRIPT" +done + +# test for user zshrc +if [ -f $AM_PROMPT/user/zshrc ]; then + . "$AM_PROMPT/user/zshrc" +fi diff --git a/template/bash_profile b/template/bash_profile index 5c05fd4..eb63a9c 100644 --- a/template/bash_profile +++ b/template/bash_profile @@ -1,5 +1,8 @@ #!/usr/bin/env bash -if [ -f $HOME/.am/prompt/bashrc ]; then - source $HOME/.am/prompt/bashrc +# determine if bash exists +if [ -f "$HOME/.bashrc" ]; then + + # load bash + source "$HOME/.bashrc" fi diff --git a/template/bashrc b/template/bashrc new file mode 100644 index 0000000..ff4558a --- /dev/null +++ b/template/bashrc @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +if [ ! -z "${AM_PROMPT_BASH:-}" ]; then + return +fi + +echo +echo "prompt: using bash shell" + +if [ -f $HOME/.am/prompt/sh/profile ]; then + . $HOME/.am/prompt/sh/profile +fi + +if [ -f $HOME/.am/prompt/bash/bashrc ]; then + . $HOME/.am/prompt/bash/bashrc +fi + +AM_PROMPT_BASH=1 diff --git a/template/profile b/template/profile new file mode 100644 index 0000000..6dfcc36 --- /dev/null +++ b/template/profile @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +echo +echo "prompt: using dash shell" + +if [ -f $HOME/.am/prompt/sh/profile ]; then + . $HOME/.am/prompt/sh/profile +fi diff --git a/template/zprofile b/template/zprofile new file mode 100644 index 0000000..95a732a --- /dev/null +++ b/template/zprofile @@ -0,0 +1,8 @@ +#!/usr/bin/env zsh + +# determine if zshrc exists +if [ -f "$HOME/.zshrc" ]; then + + # load zshrc + . "$HOME/.zshrc" +fi diff --git a/template/zshrc b/template/zshrc new file mode 100644 index 0000000..549189a --- /dev/null +++ b/template/zshrc @@ -0,0 +1,18 @@ +#!/usr/bin/env zsh + +if [ ! -z "${AM_PROMPT_ZSH:-}" ]; then + return +fi + +echo +echo "prompt: using zsh shell" + +if [ -f $HOME/.am/prompt/sh/profile ]; then + . $HOME/.am/prompt/sh/profile +fi + +if [ -f $HOME/.am/prompt/zsh/zshrc ]; then + . $HOME/.am/prompt/zsh/zshrc +fi + +AM_PROMPT_ZSH=1 diff --git a/uname/install-Darwin.sh b/uname/install-Darwin.sh deleted file mode 100644 index 5677a5e..0000000 --- a/uname/install-Darwin.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash - -__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...' - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - 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 - - 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' - fi - - if [[ "$SHELL" != "/usr/local/bin/bash" ]]; then - __am-prompt-success 'setting updated bash to default shell for user...' - sudo chsh -s /usr/local/bin/bash $USER - fi - - mkdir -p /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 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 -} - -__am-prompt-install-darwin diff --git a/uname/install-centos.sh b/uname/install-centos.sh deleted file mode 100644 index 4d8558b..0000000 --- a/uname/install-centos.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -__am-prompt-install-centos() { - local YUM=$(command -v dnf 2>/dev/null || command -v yum) - local PACKAGES=(curl file git which) - - __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 deleted file mode 100644 index 66add1d..0000000 --- a/uname/install-debian.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -__am-prompt-install-debian() { - 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-debian diff --git a/uname/install-fedora.sh b/uname/install-fedora.sh deleted file mode 100644 index 2279bf8..0000000 --- a/uname/install-fedora.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -source "$SCRIPT_DIR/uname/install-centos.sh" diff --git a/uname/install-linux.sh b/uname/install-linux.sh deleted file mode 100644 index 3f7ed10..0000000 --- a/uname/install-linux.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/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 "yes | $(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh) && brew config" - - 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...' - sudo chsh -s $BASH_SHELL $USER - 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 deleted file mode 100755 index ecdae6b..0000000 --- a/uname/install-linuxmint.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/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 deleted file mode 100644 index 6660e94..0000000 --- a/uname/install-ubuntu.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -source "$SCRIPT_DIR/uname/install-debian.sh"