From 72f23e717846d0a9b3128e5a698f78a641da5f85 Mon Sep 17 00:00:00 2001 From: "Deavon M. McCaffery" Date: Wed, 14 Dec 2016 01:09:06 -0800 Subject: [PATCH] feat(linux): add support for debian, ubuntu, and fedora --- README.md | 2 +- install.sh | 40 ++++++++------- src/bashrc | 18 +++---- src/scripts/Darwin/add-ssh-keys.sh | 3 +- src/scripts/Darwin/flush-dns.sh | 2 +- src/scripts/Darwin/hide-all.sh | 2 +- src/scripts/Darwin/set-nvm.sh | 24 --------- src/scripts/Darwin/show-all.sh | 2 +- src/scripts/Darwin/themes.sh | 2 +- src/scripts/add-bookmark.sh | 4 +- src/scripts/clear-screen.sh | 2 +- src/scripts/do-repeat.sh | 2 +- src/scripts/docker-gc.sh | 2 +- src/scripts/dotnet-install.sh | 50 +++++++++++++++++++ src/scripts/git-extensions.sh | 8 +-- src/scripts/{Darwin => }/git-extras.sh | 2 +- src/scripts/list-directory.sh | 2 +- src/scripts/remove-bookmark.sh | 16 +++--- src/scripts/remove-directory.sh | 2 +- src/scripts/set-nvm.sh | 28 +++++++++++ src/scripts/set-prompt.sh | 10 ++-- src/scripts/show-boomarks.sh | 2 +- src/scripts/show-colors.sh | 2 +- src/scripts/show-history.sh | 2 +- src/scripts/show-profile.sh | 2 +- src/scripts/source-os.sh | 24 +++++++++ src/scripts/source-uname.sh | 17 ------- template/bash_profile | 4 +- uname/install-Darwin.sh | 19 ++++--- uname/install-MINGW64_NT-10.0.sh | 4 -- uname/{install-Linux.sh => install-debian.sh} | 9 ++-- uname/install-fedora.sh | 17 +++++++ uname/install-ubuntu.sh | 27 ++++++++++ 33 files changed, 230 insertions(+), 122 deletions(-) delete mode 100644 src/scripts/Darwin/set-nvm.sh create mode 100644 src/scripts/dotnet-install.sh rename src/scripts/{Darwin => }/git-extras.sh (84%) create mode 100644 src/scripts/set-nvm.sh create mode 100644 src/scripts/source-os.sh delete mode 100644 src/scripts/source-uname.sh delete mode 100644 uname/install-MINGW64_NT-10.0.sh rename uname/{install-Linux.sh => install-debian.sh} (86%) create mode 100644 uname/install-fedora.sh create mode 100644 uname/install-ubuntu.sh diff --git a/README.md b/README.md index ee32ad3..a84c414 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ customization (aside from the prompt). Installing PulseBridge Prompt is a 1 step process: ``` bash -curl -L https://raw.github.com/pulsebridge/prompt/master/bootstrap.sh | /usr/bin/env bash +curl -fsSL https://raw.githubusercontent.com/pulsebridge/prompt/master/bootstrap.sh | /usr/bin/env bash ``` (Optional) Open the included Monokai theme (currently only supported on OS X): diff --git a/install.sh b/install.sh index c81a0c5..5c0e7b3 100755 --- a/install.sh +++ b/install.sh @@ -3,6 +3,7 @@ CLR_SUCCESS="\033[1;32m" # BRIGHT GREEN CLR_CLEAR="\033[0m" # DEFAULT COLOR +PULSEBRIDGE_PATH="$HOME/.pulsebridge" PULSEBRIDGE_PROMPT="$HOME/.pulsebridge/prompt" function success() { @@ -10,14 +11,14 @@ function success() { } now=$(date +"%Y%m%d_%H%M%S") -backup_path="backup/$now" +backup_path="$PULSEBRIDGE_PATH/backup/prompt/$now" -success "Creating backup path : $pwd/backup/$now..." -mkdir -p "backup/$now" 1>/dev/null +success "Creating backup path : $backup_path..." +mkdir -p "$backup_path" 1>/dev/null -if test -d $PULSEBRIDGE_PROMPT; then +if [ -d $PULSEBRIDGE_PROMPT ]; then success "Backing up $PULSEBRIDGE_PROMPT..." - cp -R $PULSEBRIDGE_PROMPT/* "backup/$now" 1>/dev/null + cp -R $PULSEBRIDGE_PROMPT/* "$backup_path" 1>/dev/null success "Removing $PULSEBRIDGE_PROMPT..." rm -rf $PULSEBRIDGE_PROMPT 1>/dev/null @@ -29,7 +30,7 @@ mkdir -p $PULSEBRIDGE_PROMPT/bin 1>/dev/null success "Installing PulseBridge Prompt to $PULSEBRIDGE_PROMPT..." cp -Rf src/* $PULSEBRIDGE_PROMPT 1>/dev/null -if test -f $backup_path/scripts/bookmarks.sh; then +if [ -f $backup_path/scripts/bookmarks.sh ]; then success "Restoring bookmarks..." cp -R $backup_path/scripts/bookmarks.sh $PULSEBRIDGE_PROMPT/scripts 1>/dev/null fi @@ -38,7 +39,7 @@ for template in template/*; do name=$(basename "$template") path=$HOME/.${name} - if test -f $path; then + if [ -f $path ]; then success "Backing up ${name}..." cp $path $backup_path/$name fi @@ -51,12 +52,15 @@ BASH_COMPLETION=$LOCAL_PREFIX/etc/bash_completion.d UNAME=$(uname) UNAME_INSTALL="./uname/install-$UNAME.sh" -if test -f $UNAME_INSTALL; then - source $UNAME_INSTALL +if [ -e /etc/os-release ]; then + . /etc/os-release + + UNAME_INSTALL="./uname/install-$ID.sh" fi -DOCKER_GC_NAME=docker-gc -DOCKER_GC_URI=https://raw.githubusercontent.com/spotify/docker-gc/master/docker-gc +if [ -f $UNAME_INSTALL ]; then + source $UNAME_INSTALL +fi GIT_PROMPT_NAME=git-prompt.sh GIT_COMPLETE_NAME=git-flow-completion.bash @@ -64,32 +68,32 @@ GIT_PROMPT_URI=https://raw.githubusercontent.com/lyze/posh-git-sh/master/$GIT_PR GIT_COMPLETE_URI=https://raw.githubusercontent.com/petervanderdoes/git-flow-completion/develop/$GIT_COMPLETE_NAME PROMPT_COMPLETION=$PULSEBRIDGE_PROMPT/completions -if test -f "$BASH_COMPLETION/$GIT_COMPLETE_NAME"; then +if [ -f "$BASH_COMPLETION/$GIT_COMPLETE_NAME" ]; then success "Removing git flow bash completion..." sudo rm -rf "$BASH_COMPLETION/$GIT_COMPLETE_NAME" 1>/dev/null fi -if test -f "$BASH_COMPLETION/$GIT_PROMPT_NAME"; then +if [ -f "$BASH_COMPLETION/$GIT_PROMPT_NAME" ]; then success "Removing crappy git-prompt..." sudo rm -rf "$BASH_COMPLETION/$GIT_PROMPT_NAME" 1>/dev/null fi -if ! test -d "$PROMPT_COMPLETION"; then +if [ ! -d "$PROMPT_COMPLETION" ]; then mkdir -p "$PROMPT_COMPLETION" 1>/dev/null fi success "Downloading better git-prompt..." -result=$(curl -s -L -D - "$GIT_PROMPT_URI" -o "$PROMPT_COMPLETION/$GIT_PROMPT_NAME" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/") +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/") -if test "$result" = "200"; then +if [ "$result" = "200" ]; then success "Successfully installed git-prompt..." chmod +x "PROMPT_COMPLETION/$GIT_PROMPT_NAME" 1>/dev/null 2>&1 fi success "Downloading git-flow completion..." -result=$(curl -s -L -D - "$GIT_COMPLETE_URI" -o "$PROMPT_COMPLETION/$GIT_COMPLETE_NAME" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/") +result=$(curl -sLD- "$GIT_COMPLETE_URI" -o "$PROMPT_COMPLETION/$GIT_COMPLETE_NAME" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/") -if test "$result" = "200"; then +if [ "$result" = "200" ]; then success "Successfully installed git-flow completion..." chmod +x "$PROMPT_COMPLETION/$GIT_COMPLETE_NAME" 1>/dev/null 2>&1 fi diff --git a/src/bashrc b/src/bashrc index aaed255..f0e5627 100644 --- a/src/bashrc +++ b/src/bashrc @@ -49,43 +49,43 @@ export HISTCONTROL=ignoredubs if type brew 1>/dev/null 2>&1; then export LOCAL_PREFIX=$(brew --prefix) -elif test -d $LOCALAPPDATA/git; then +elif [ -d $LOCALAPPDATA/git ]; then export LOCAL_PREFIX=$(echo "/$LOCALAPPDATA/git" | sed -e 's/\\/\//g' -e 's/://') else export LOCAL_PREFIX=/usr/local fi # system binds for bash completion (for interactive terminals) -if test -t 1; then +if [ -t 1 ]; then bind "set completion-ignore-case on" # ignore strict case sensitivity bind "set bell-style none" # turn off audible alerts bind "set show-all-if-ambiguous on" # show completion with double tap fi # turn on advanced completion -if test -f /etc/bash_completion; then - source /etc/bash_completion +if [ -f /etc/bash_completion ]; then + . /etc/bash_completion fi # determine if bash completion exists elsewhere -if test -f /usr/share/bash-completion/bash_completion; then - source /usr/share/bash-completion/bash_completion +if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion fi PULSEBRIDGE_PROMPT=$HOME/.pulsebridge/prompt # source completions for completion in $PULSEBRIDGE_PROMPT/completions/*; do - source $completion + . $completion done # source scripts for script in $PULSEBRIDGE_PROMPT/scripts/*.sh; do - source $script + . $script done # test for prompt bin -if test -d $PULSEBRIDGE_PROMPT/bin; then +if [ -d $PULSEBRIDGE_PROMPT/bin ]; then # append prompt to path export PATH=$PATH:$PULSEBRIDGE_PROMPT/bin fi diff --git a/src/scripts/Darwin/add-ssh-keys.sh b/src/scripts/Darwin/add-ssh-keys.sh index cf01260..7f1ce4d 100644 --- a/src/scripts/Darwin/add-ssh-keys.sh +++ b/src/scripts/Darwin/add-ssh-keys.sh @@ -1,8 +1,9 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'add-ssh-keys' fi + function add-ssh-keys() { ssh-add -A 2>/dev/null } diff --git a/src/scripts/Darwin/flush-dns.sh b/src/scripts/Darwin/flush-dns.sh index f7cfada..36c3d2d 100644 --- a/src/scripts/Darwin/flush-dns.sh +++ b/src/scripts/Darwin/flush-dns.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'flush-dns' fi diff --git a/src/scripts/Darwin/hide-all.sh b/src/scripts/Darwin/hide-all.sh index baace1a..68ad64e 100644 --- a/src/scripts/Darwin/hide-all.sh +++ b/src/scripts/Darwin/hide-all.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'hide-all' fi diff --git a/src/scripts/Darwin/set-nvm.sh b/src/scripts/Darwin/set-nvm.sh deleted file mode 100644 index 0efacb4..0000000 --- a/src/scripts/Darwin/set-nvm.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -if test -n "${PROMPT_DEBUG+1}"; then - echo 'set-nvm' -fi - -function set-nvm() -{ - nvm_path=$(brew --prefix nvm) - - if test -d $nvm_path; then - if ! test -d $HOME/.nvm; then - mkdir -p $HOME/.nvm - fi - - export NVM_DIR=$HOME/.nvm - - source $nvm_path/nvm.sh - fi - - nvm use --lts -} - -set-nvm \ No newline at end of file diff --git a/src/scripts/Darwin/show-all.sh b/src/scripts/Darwin/show-all.sh index 27c6145..52d0800 100644 --- a/src/scripts/Darwin/show-all.sh +++ b/src/scripts/Darwin/show-all.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'show-all' fi function show-all() { diff --git a/src/scripts/Darwin/themes.sh b/src/scripts/Darwin/themes.sh index 541fd56..02c9071 100644 --- a/src/scripts/Darwin/themes.sh +++ b/src/scripts/Darwin/themes.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'themes' fi diff --git a/src/scripts/add-bookmark.sh b/src/scripts/add-bookmark.sh index 3abaa78..08c1b68 100644 --- a/src/scripts/add-bookmark.sh +++ b/src/scripts/add-bookmark.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'add-bookmark' fi function add-bookmark() { # make sure that a bookmark was specified. - if test -z "${1+1}"; then + if [ -z "${1:-}" ]; then echo USAGE: add-bookmark NAME echo ' NAME : a title for your bookmark' else diff --git a/src/scripts/clear-screen.sh b/src/scripts/clear-screen.sh index 8a63d37..e4021df 100644 --- a/src/scripts/clear-screen.sh +++ b/src/scripts/clear-screen.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'clear-screen' fi diff --git a/src/scripts/do-repeat.sh b/src/scripts/do-repeat.sh index 3bd0b5b..fbe0679 100644 --- a/src/scripts/do-repeat.sh +++ b/src/scripts/do-repeat.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'do-repeat' fi diff --git a/src/scripts/docker-gc.sh b/src/scripts/docker-gc.sh index 1813562..6fac86d 100644 --- a/src/scripts/docker-gc.sh +++ b/src/scripts/docker-gc.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'docker-gc' fi diff --git a/src/scripts/dotnet-install.sh b/src/scripts/dotnet-install.sh new file mode 100644 index 0000000..ae3eb5a --- /dev/null +++ b/src/scripts/dotnet-install.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +if [ ! -z "${PROMPT_DEBUG:-}" ]; then + echo 'dotnet-install' +fi + +safe-exec() { + local CMD=$1 + shift + + $CMD "$@" 2>&1 + + local EXIT_CODE=$? + + if [ $EXIT_CODE -ne 0 ]; then + exit $EXIT_CODE + fi +} + +function dotnet-install() { + if type dotnet 1>/dev/null 2>&1; then + return + fi + + if [ ! -z "${1:-}" ]; then + export DOTNET_INSTALL_DIR=$1 + fi + + if [ -z "${DOTNET_INSTALL_DIR:-}" ]; then + export DOTNET_INSTALL_DIR=$HOME/.dotnet + fi + + local DOTNET_URI=https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview2.1/scripts/obtain/dotnet-install.sh + local DOTNET_INSTALL_SH=$DOTNET_INSTALL_DIR/dotnet-install.sh + + if [ ! -d $DOTNET_INSTALL_DIR ]; then + mkdir -p $DOTNET_INSTALL_DIR + fi + + curl -fSsL $DOTNET_URI -o $DOTNET_INSTALL_SH 1>/dev/null 2>&1 + + safe-exec chmod +x $DOTNET_INSTALL_SH + safe-exec $DOTNET_INSTALL_SH + safe-exec rm -rf $DOTNET_INSTALL_SH + + mkdir -p /usr/local/share 1>/dev/null 2>&1 + ln -s $DOTNET_INSTALL_DIR /usr/local/share 1>/dev/null 2>&1 + + reset +} \ No newline at end of file diff --git a/src/scripts/git-extensions.sh b/src/scripts/git-extensions.sh index 088d41c..4b80ed0 100644 --- a/src/scripts/git-extensions.sh +++ b/src/scripts/git-extensions.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'git-extensions' fi @@ -13,12 +13,12 @@ git-clone() { local url=$1 local name=$2 - if test -z "$url"; then + if [ -z "${url:-}" ]; then echo "You must specify a url, which is the first parameter." return fi - if test -z "$name"; then + if [ -z "${name:-}" ]; then echo "You must specify a directory name, which is the second parameter." return fi @@ -48,7 +48,7 @@ git-init() { local name=$1 - if test -z "$name"; then + if [ -z "${name:-}" ]; then name="." fi diff --git a/src/scripts/Darwin/git-extras.sh b/src/scripts/git-extras.sh similarity index 84% rename from src/scripts/Darwin/git-extras.sh rename to src/scripts/git-extras.sh index 3cad125..53d1b88 100644 --- a/src/scripts/Darwin/git-extras.sh +++ b/src/scripts/git-extras.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'git-extras' fi diff --git a/src/scripts/list-directory.sh b/src/scripts/list-directory.sh index e016d3c..23d33c4 100644 --- a/src/scripts/list-directory.sh +++ b/src/scripts/list-directory.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'list-directory' fi diff --git a/src/scripts/remove-bookmark.sh b/src/scripts/remove-bookmark.sh index 2c606a5..8d68ca5 100644 --- a/src/scripts/remove-bookmark.sh +++ b/src/scripts/remove-bookmark.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'remove-bookmark' fi @@ -9,21 +9,21 @@ remove-bookmark() { local r= local scripts_path=$HOME/.pulsebridge/prompt/scripts - if ! test -z "$b"; then + if [ ! -z "${b:-}" ]; then r=$(command grep -s -m 1 ^$b $scripts_path/bookmarks.sh) - elif test -z "$2"; then + elif [ -z "${2:-}" ]; then r=$(command grep -s -m 1 \"$PWD\"$ $scripts_path/bookmarks.sh) fi - if ! test -z "$r"; then - test -z "$2" && ( echo Removing bookmark: $r ) + if [ ! -z "${r:-}" ]; then + [ -z "${2:-}" ] && ( echo Removing bookmark: $r ) command grep -s -v $r $scripts_path/bookmarks.sh >> $scripts_path/bookmarks1.sh mv -f $scripts_path/bookmarks1.sh $scripts_path/bookmarks.sh - source $scripts_path/bookmarks.sh - else - test -z "$2" && ( echo No bookmark was declared for the specified title or address. ) + . $scripts_path/bookmarks.sh + elif [ -z "${2:-}" ]; then + echo No bookmark was declared for the specified title or address. fi } diff --git a/src/scripts/remove-directory.sh b/src/scripts/remove-directory.sh index 89f3f67..13eb262 100644 --- a/src/scripts/remove-directory.sh +++ b/src/scripts/remove-directory.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'remove-directory' fi diff --git a/src/scripts/set-nvm.sh b/src/scripts/set-nvm.sh new file mode 100644 index 0000000..1939cc4 --- /dev/null +++ b/src/scripts/set-nvm.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +if [ ! -z "${PROMPT_DEBUG:-}" ]; then + echo 'set-nvm' +fi + +function set-nvm() +{ + if type brew 1>/dev/null 2>&1; then + local nvm_path=$(brew --prefix nvm) + else + local nvm_path=$(which nvm) + fi + + if [ -d $nvm_path ]; then + if [ ! -d $HOME/.nvm ]; then + mkdir -p $HOME/.nvm + fi + + export NVM_DIR=$HOME/.nvm + + . $nvm_path/nvm.sh + fi + + nvm use --lts +} + +set-nvm \ No newline at end of file diff --git a/src/scripts/set-prompt.sh b/src/scripts/set-prompt.sh index 93e68ef..70d4603 100644 --- a/src/scripts/set-prompt.sh +++ b/src/scripts/set-prompt.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'set-prompt' fi @@ -9,17 +9,17 @@ function emit-prompt-arrow() { local CLR_PROMPT=$CLR_USER_PROMPT # set color for staff user (administrator) - if ! test -z "$(command id -Gn 2>/dev/null | grep -s -o admin)"; then + 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 test $(id -u) -eq 0; then + if [ $(id -u) = 0 ]; then CLR_PROMPT=$CLR_ROOT_PROMPT fi # set the color for an ssh session - if test -n "${SSH_CONNECTION+1}"; then + if [ ! -z "${SSH_CONNECTION:-}" ]; then CLR_PROMPT=$CLR_SSH_PROMPT # emit the prompt using the correct color @@ -33,7 +33,7 @@ function emit-prompt-arrow() { function set-prompt() { local bash_completion=$LOCAL_PREFIX/etc/bash_completion.d - if test -d "$bash_completion"; then + if [ -d "$bash_completion" ]; then for f in $bash_completion/*; do source $f done diff --git a/src/scripts/show-boomarks.sh b/src/scripts/show-boomarks.sh index 6c442c2..7286119 100644 --- a/src/scripts/show-boomarks.sh +++ b/src/scripts/show-boomarks.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'show-bookmarks' fi diff --git a/src/scripts/show-colors.sh b/src/scripts/show-colors.sh index 6d0459c..e81365d 100644 --- a/src/scripts/show-colors.sh +++ b/src/scripts/show-colors.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'show-colors' fi diff --git a/src/scripts/show-history.sh b/src/scripts/show-history.sh index 3bfa03d..f760ee8 100644 --- a/src/scripts/show-history.sh +++ b/src/scripts/show-history.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'show-history' fi diff --git a/src/scripts/show-profile.sh b/src/scripts/show-profile.sh index 774ff96..d4f64cc 100644 --- a/src/scripts/show-profile.sh +++ b/src/scripts/show-profile.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -if test -n "${PROMPT_DEBUG+1}"; then +if [ ! -z "${PROMPT_DEBUG:-}" ]; then echo 'show-profile' fi diff --git a/src/scripts/source-os.sh b/src/scripts/source-os.sh new file mode 100644 index 0000000..db91d52 --- /dev/null +++ b/src/scripts/source-os.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +if [ ! -z "${PROMPT_DEBUG:-}" ]; then + echo 'source-os' +fi + +function source-os() { + local uname=$(uname) + local unamepath=$HOME/.pulsebridge/prompt/scripts/$uname + + if [ -e /etc/os-release ]; then + . /etc/os-release + + local unamepath=$HOME/.pulsebridge/prompt/scripts/$ID + fi + + if [ -d $unamepath ]; then + for f in $unamepath/*; do + . $f + done + fi +} + +source-os \ No newline at end of file diff --git a/src/scripts/source-uname.sh b/src/scripts/source-uname.sh deleted file mode 100644 index a36af25..0000000 --- a/src/scripts/source-uname.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -if test -n "${PROMPT_DEBUG+1}"; then - echo 'source-uname' -fi - -function source-uname() { - local unamepath=$HOME/.pulsebridge/prompt/scripts/$(uname) - - if test -d $unamepath; then - for f in $unamepath/*; do - source $f - done - fi -} - -source-uname \ No newline at end of file diff --git a/template/bash_profile b/template/bash_profile index 3371d5c..931077a 100644 --- a/template/bash_profile +++ b/template/bash_profile @@ -1,9 +1,9 @@ #!/usr/bin/env bash -if test -f $HOME/.pulsebridge/prompt/bashrc; then +if [ -e $HOME/.pulsebridge/prompt/bashrc ]; then source $HOME/.pulsebridge/prompt/bashrc fi -if test -f $HOME/.dotnet/dotnet; then +if [ -e $HOME/.dotnet/dotnet ]; then export PATH=$HOME/.dotnet:$PATH fi \ No newline at end of file diff --git a/uname/install-Darwin.sh b/uname/install-Darwin.sh index 4f6e3e1..17841ac 100644 --- a/uname/install-Darwin.sh +++ b/uname/install-Darwin.sh @@ -12,8 +12,6 @@ if ! type brew 1>/dev/null 2>&1; then ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" fi -LOCAL_PREFIX=$(brew --prefix) - success "Updating Homebrew..." brew update 1>/dev/null @@ -33,20 +31,25 @@ for pkg in openssl git git-extras git-flow-avh nvm; do success "Installing $pkg..." brew install ${pkg} 1>/dev/null 2>&1 fi + + mkdir -p /usr/local/lib 1>/dev/null 2>&1 + ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/ 1>/dev/null 2>&1 + ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/ 1>/dev/null 2>&1 done nvm_path=$(brew --prefix nvm) -if test -d $nvm_path; then - if ! test -d $HOME/.nvm; then - mkdir -p $HOME/.nvm - fi +if [ -d $nvm_path ]; then + export NVM_DIR=$HOME/.nvm - export NVM_DIR=~/.nvm + if [ ! -d $NVM_DIR ]; then + mkdir -p $NVM_DIR + fi . $nvm_path/nvm.sh - nvm use --lts 1>/dev/null + nvm install --lts 1>/dev/null 2>&1 + nvm use --lts 1>/dev/null 2>&1 fi success "Setting git credential helper to use the macOS keychain..." diff --git a/uname/install-MINGW64_NT-10.0.sh b/uname/install-MINGW64_NT-10.0.sh deleted file mode 100644 index 6464f02..0000000 --- a/uname/install-MINGW64_NT-10.0.sh +++ /dev/null @@ -1,4 +0,0 @@ -LOCAL_PREFIX=$LOCALAPPDATA/git -BASH_COMPLETION=$LOCAL_PREFIX/etc/bash_completion.d - -mkdir -p "$BASH_COMPLETION" 1>/dev/null \ No newline at end of file diff --git a/uname/install-Linux.sh b/uname/install-debian.sh similarity index 86% rename from uname/install-Linux.sh rename to uname/install-debian.sh index 6132a7e..5fa6098 100644 --- a/uname/install-Linux.sh +++ b/uname/install-debian.sh @@ -5,9 +5,6 @@ function success() { echo -e "${CLR_SUCCESS}$1${CLR_CLEAR}" } -LOCAL_PREFIX=/usr/share -BASH_COMPLETION="${LOCAL_PREFIX}/bash-completion/completions" - sudo add-apt-repository ppa:pdoes/gitflow-avh -y 1>/dev/null 2>&1 sudo add-apt-repository ppa:git-core/ppa -y 1>/dev/null 2>&1 sudo apt-get update 1>/dev/null @@ -18,11 +15,13 @@ for pkg in git-flow; do fi done -for pkg in openssl git git-extras git-flow build-essential libssl-dev; do +for pkg in openssl git git-extras git-flow build-essential libssl-dev curl libunwind8 gettext; do success "Installing $pkg..." sudo apt-get install -y ${pkg} done sudo apt-get autoremove -y 1>/dev/null -curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash \ No newline at end of file +curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash +nvm install --lts 1>/dev/null +nvm use --lts 1>/dev/null \ No newline at end of file diff --git a/uname/install-fedora.sh b/uname/install-fedora.sh new file mode 100644 index 0000000..0a6b65f --- /dev/null +++ b/uname/install-fedora.sh @@ -0,0 +1,17 @@ +CLR_SUCCESS="\033[1;32m" # BRIGHT GREEN +CLR_CLEAR="\033[0m" # DEFAULT COLOR + +function success() { + echo -e "${CLR_SUCCESS}$1${CLR_CLEAR}" +} + +for pkg in openssl git install libunwind libicu; do + success "Installing $pkg..." + sudo dnf ${pkg} +done + +curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash +nvm install --lts 1>/dev/null +nvm use --lts 1>/dev/null + +wget --no-check-certificate -q https://raw.github.com/petervanderdoes/gitflow-avh/develop/contrib/gitflow-installer.sh && sudo bash gitflow-installer.sh install stable; rm gitflow-installer.sh \ No newline at end of file diff --git a/uname/install-ubuntu.sh b/uname/install-ubuntu.sh new file mode 100644 index 0000000..5fa6098 --- /dev/null +++ b/uname/install-ubuntu.sh @@ -0,0 +1,27 @@ +CLR_SUCCESS="\033[1;32m" # BRIGHT GREEN +CLR_CLEAR="\033[0m" # DEFAULT COLOR + +function success() { + echo -e "${CLR_SUCCESS}$1${CLR_CLEAR}" +} + +sudo add-apt-repository ppa:pdoes/gitflow-avh -y 1>/dev/null 2>&1 +sudo add-apt-repository ppa:git-core/ppa -y 1>/dev/null 2>&1 +sudo apt-get update 1>/dev/null + +for pkg in git-flow; do + if apt list $pkg | grep -q "&${pkg}(.*)\[installed\]$" 2>/dev/null; then + sudo apt-get remove -y $pkg 1>/dev/null + fi +done + +for pkg in openssl git git-extras git-flow build-essential libssl-dev curl libunwind8 gettext; do + success "Installing $pkg..." + sudo apt-get install -y ${pkg} +done + +sudo apt-get autoremove -y 1>/dev/null + +curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash +nvm install --lts 1>/dev/null +nvm use --lts 1>/dev/null \ No newline at end of file