-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(update): add support for self-update
- Loading branch information
Deavon M. McCaffery
committed
Dec 14, 2016
1 parent
8d6e2fb
commit ff98806
Showing
10 changed files
with
168 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ ! -z "${PROMPT_DEBUG:-}" ]; then | ||
echo 'add-var' | ||
fi | ||
|
||
add-var-usage() { | ||
echo "add-var <name> <value>" | ||
echo ' name : a name for your variable' | ||
echo ' value : a value for your variable' | ||
} | ||
|
||
function add-var() { | ||
# make sure that a bookmark was specified. | ||
if [ -z "${1:-}" ]; then | ||
echo 'add-var: missing <name>' | ||
add-var-usage | ||
return | ||
fi | ||
|
||
if [ -z "${2:-}" ]; then | ||
echo 'add-var: missing <value>' | ||
add-var-usage | ||
return | ||
fi | ||
|
||
# make sure we remove any existing variable before defining another one | ||
remove-var $1 silent | ||
local v="$1"=\"$2\" | ||
|
||
echo Adding varable: $v | ||
echo $v >> $HOME/.pulsebridge/prompt/scripts/variables.sh | ||
. $HOME/.pulsebridge/prompt/scripts/variables.sh | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ ! -z "${PROMPT_DEBUG:-}" ]; then | ||
echo 'remove-backup' | ||
fi | ||
|
||
remove-backup() { | ||
rm -rf $HOME/.pulsebridge/prompt/backup 2>/dev/null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ ! -z "${PROMPT_DEBUG:-}" ]; then | ||
echo 'remove-var' | ||
fi | ||
|
||
remove-var() { | ||
local v=$1 | ||
local r= | ||
local scripts_path=$HOME/.pulsebridge/prompt/scripts | ||
|
||
if [ -z "${v:-}" ]; then | ||
r=$(grep -s -m 1 ^$v $scripts_path/variables.sh) | ||
fi | ||
|
||
if [ ! -z "${r:-}" ]; then | ||
[ -z "${2:-}" ] && (echo Removing variable: $r) | ||
|
||
grep -s -v $r $scripts_path/variables.sh >> $scripts_path/variables1.sh | ||
mv -f $scripts_path/variables1.sh $scripts_path/variables.sh | ||
|
||
. $scripts_path/variables.sh | ||
elif [ -z "${2:-}" ]; then | ||
echo No variable was declared for the specified name. | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ ! -z "${PROMPT_DEBUG:-}" ]; then | ||
echo 'show-vars' | ||
fi | ||
|
||
function show-vars() { | ||
cat $HOME/.pulsebridge/prompt/scripts/variables.sh 2>/dev/null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ ! -z "${PROMPT_DEBUG:-}" ]; then | ||
echo 'update-prompt' | ||
fi | ||
|
||
function update-prompt() { | ||
local SHA=$(git-sha) | ||
local SHA_PATH=$HOME/.pulsebridge/prompt/$SHA | ||
|
||
if [ -f $SHA_PATH ]; then | ||
echo "prompt: latest version already installed: $SHA" | ||
return 1 | ||
fi | ||
|
||
local UPDATE_URI="https://github.com/pulsebridge/prompt/archive/master.tar.gz" | ||
local UPDATE_TEMP=$(mktemp -d -t pb_prompt) | ||
|
||
pushd $UPDATE_TEMP 1>/dev/null | ||
curl -skL $UPDATE_URI | tar zx | ||
pushd prompt-master 1>/dev/null | ||
./install.sh | ||
popd 1>/dev/null | ||
|
||
rm -rf $UPDATE_TEMP 1>/dev/null | ||
} |