Skip to content

Commit

Permalink
feat(linux): add support for debian, ubuntu, and fedora
Browse files Browse the repository at this point in the history
  • Loading branch information
Deavon M. McCaffery committed Dec 14, 2016
1 parent 63b3084 commit 72f23e7
Show file tree
Hide file tree
Showing 33 changed files with 230 additions and 122 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
40 changes: 22 additions & 18 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
CLR_SUCCESS="\033[1;32m" # BRIGHT GREEN
CLR_CLEAR="\033[0m" # DEFAULT COLOR

PULSEBRIDGE_PATH="$HOME/.pulsebridge"
PULSEBRIDGE_PROMPT="$HOME/.pulsebridge/prompt"

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

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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -51,45 +52,48 @@ 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
GIT_PROMPT_URI=https://raw.githubusercontent.com/lyze/posh-git-sh/master/$GIT_PROMPT_NAME
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
Expand Down
18 changes: 9 additions & 9 deletions src/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/scripts/Darwin/add-ssh-keys.sh
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/Darwin/flush-dns.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

if test -n "${PROMPT_DEBUG+1}"; then
if [ ! -z "${PROMPT_DEBUG:-}" ]; then
echo 'flush-dns'
fi

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/Darwin/hide-all.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

if test -n "${PROMPT_DEBUG+1}"; then
if [ ! -z "${PROMPT_DEBUG:-}" ]; then
echo 'hide-all'
fi

Expand Down
24 changes: 0 additions & 24 deletions src/scripts/Darwin/set-nvm.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/scripts/Darwin/show-all.sh
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/Darwin/themes.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

if test -n "${PROMPT_DEBUG+1}"; then
if [ ! -z "${PROMPT_DEBUG:-}" ]; then
echo 'themes'
fi

Expand Down
4 changes: 2 additions & 2 deletions src/scripts/add-bookmark.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/clear-screen.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

if test -n "${PROMPT_DEBUG+1}"; then
if [ ! -z "${PROMPT_DEBUG:-}" ]; then
echo 'clear-screen'
fi

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/do-repeat.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

if test -n "${PROMPT_DEBUG+1}"; then
if [ ! -z "${PROMPT_DEBUG:-}" ]; then
echo 'do-repeat'
fi

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/docker-gc.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

if test -n "${PROMPT_DEBUG+1}"; then
if [ ! -z "${PROMPT_DEBUG:-}" ]; then
echo 'docker-gc'
fi

Expand Down
50 changes: 50 additions & 0 deletions src/scripts/dotnet-install.sh
Original file line number Diff line number Diff line change
@@ -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
}
8 changes: 4 additions & 4 deletions src/scripts/git-extensions.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

if test -n "${PROMPT_DEBUG+1}"; then
if [ ! -z "${PROMPT_DEBUG:-}" ]; then
echo 'git-extensions'
fi

Expand All @@ -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
Expand Down Expand Up @@ -48,7 +48,7 @@ git-init() {

local name=$1

if test -z "$name"; then
if [ -z "${name:-}" ]; then
name="."
fi

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

if test -n "${PROMPT_DEBUG+1}"; then
if [ ! -z "${PROMPT_DEBUG:-}" ]; then
echo 'git-extras'
fi

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/list-directory.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

if test -n "${PROMPT_DEBUG+1}"; then
if [ ! -z "${PROMPT_DEBUG:-}" ]; then
echo 'list-directory'
fi

Expand Down
Loading

0 comments on commit 72f23e7

Please sign in to comment.