Skip to content

Commit

Permalink
fix: prompt updates on sierra (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmccaffery authored Mar 6, 2018
1 parent 0b0aaae commit 6147b37
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/scripts/add-bookmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ add-bookmark-usage() {

add-bookmark() {
# make sure that a bookmark was specified.
if [ -z ${1+x} ]; then
if [ -z ${1:-} ]; then
echo 'add-bookmark: missing <name>'
add-bookmark-usage
return
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/add-var.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ add-var-usage() {

add-var() {
# make sure that a bookmark was specified.
if [ -z ${1+x} ]; then
if [ -z ${1:-} ]; then
echo 'add-var: missing <name>'
add-var-usage
return
fi

if [ -z ${2+x} ]; then
if [ -z ${2:-} ]; then
echo 'add-var: missing <value>'
add-var-usage
return
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/dotnet-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ dotnet-install() {
shift
done

if [ -z ${DOTNET_INSTALL_DIR+x} ]; then
if [ -z ${DOTNET_INSTALL_DIR:-} ]; then
export DOTNET_INSTALL_DIR=$HOME/.dotnet
fi

Expand Down
6 changes: 3 additions & 3 deletions src/scripts/git-extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ git-flow-clone() {
local URL=$1
local NAME=$2

if [ -z ${URL+x} ]; then
if [ -z ${URL:-} ]; then
echo 'git-clone: you must specify a url, which is the first parameter.'
return
fi

if [ -z ${NAME+x} ]; then
if [ -z ${NAME:-} ]; then
echo 'git-clone: you must specify a directory name, which is the second parameter.'
return
fi
Expand Down Expand Up @@ -48,7 +48,7 @@ git-flow-init() {

local NAME=$1

if [ -z ${NAME+x} ]; then
if [ -z ${NAME:-} ]; then
NAME='.'
fi

Expand Down
16 changes: 8 additions & 8 deletions src/scripts/git-extras.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ git-sha() {
local REPO_NAME=$2
local BRANCH_NAME=$3

if [ -z ${ORG_NAME+x} ]; then
local ORG_NAME='automotiveMastermind'
if [ -z ${ORG_NAME:-} ]; then
ORG_NAME='automotiveMastermind'
fi

if [ -z ${REPO_NAME+x} ]; then
local REPO_NAME='prompt'
if [ -z ${REPO_NAME:-} ]; then
REPO_NAME='prompt'
fi

if [ -z ${BRANCH_NAME+x} ]; then
local BRANCH_NAME='master'
if [ -z ${BRANCH_NAME:-} ]; then
BRANCH_NAME='master'
fi

local CURL_OPT='-s'

if [ ! -z "${GH_TOKEN:-}" ]; then
local CURL_OPT="$CURL_OPT -H 'Authorization: $GH_TOKEN'"
CURL_OPT="$CURL_OPT -H 'Authorization: $GH_TOKEN'"
fi

local SHA_URI=https://api.github.com/repos/$ORG_NAME/$REPO_NAME/commits/$BRANCH_NAME
Expand All @@ -56,7 +56,7 @@ git-sha() {
git-token() {
local GH_TOKEN=$1

if [ -z ${GH_TOKEN+x} ]; then
if [ -z ${GH_TOKEN:-} ]; then
echo 'usage: git-token [token]'
else
add-var GH_TOKEN $GH_TOKEN
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/open-url.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fi
open-url() {
local url="$1"

if [ -z ${1+x} ]; then
if [ -z ${1:-} ]; then
echo 'open-url: url must be supplied'
return 1
fi
Expand Down
6 changes: 5 additions & 1 deletion src/scripts/post/post-update-prompt.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash

if [ ! -z "${AM_PROMPT_UPDATE:-}" ]; then
if [ "${AM_PROMPT_UPDATE}" == "1" ]; then
update-prompt
fi

if [ "${AM_PROMPT_UPDATE}" == "true" ]; then
update-prompt
fi
2 changes: 1 addition & 1 deletion src/scripts/remove-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fi
remove-backup() {
local BACKUP=$1

if [ -z ${BACKUP+x} ]; then
if [ -z ${BACKUP:-} ]; then
BACKUP='prompt'
fi

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/remove-bookmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ remove-bookmark() {
ROW=$(grep -s -m 1 \"$PWD\"$ "$USER_PATH/bookmarks.sh")
fi

if [ -z ${ROW+x} ]; then
if [ -z ${ROW:-} ]; then
echo 'remove-bookmark: no bookmark was found for the specified title or path.'

return 1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/remove-var.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ remove-var() {
REMOVE=$(grep -s -m 1 ^$VARIABLE $VAR_PATH)
unset $VARIABLE 1>/dev/null 2>&1

if [ -z ${REMOVE+x} ]; then
if [ -z ${REMOVE:-} ]; then
echo 'remove-var: no variable was declared for the specified name'

return 1
Expand Down
16 changes: 5 additions & 11 deletions src/scripts/set-nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ fi

__prompt-set-nvm()
{
local NVM_PATH=$(which nvm)

if [ -z ${NVM_PATH+x} ]; then
nvm use --lts --delete-prefix
eval "$(npm completion)"
return
fi

NVM_PATH=$(brew --prefix nvm 2>/dev/null)

if [ -z ${NVM_PATH+x} ]; then
Expand All @@ -25,7 +17,9 @@ __prompt-set-nvm()
return
fi

source "$NVM_PATH/nvm.sh"
nvm use --lts --delete-prefix
eval "$(npm completion)"
if [ -f "$NVM_PATH/nvm.sh" ]; then
export NVM_DIR="${HOME}/.nvm"
source "$NVM_PATH/nvm.sh"
eval "$(npm completion)"
fi
}
8 changes: 4 additions & 4 deletions src/scripts/update-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ update-prompt() {
local SHA=$(git-sha)
local SHA_PATH=$HOME/.am/prompt/.sha

if [ "${1+x}" = "--force" ]; then
if [ "${1:-}" = "--force" ]; then
rm -rf $SHA_PATH 1>/dev/null 2>&1
fi

remove-backup

if [ -f ${SHA_PATH+x} ]; then
if [ -f ${SHA_PATH:-} ]; then
CURRENT_SHA=$(cat $SHA_PATH)

if [ -z ${SHA+x} ]; then
if [ -z ${SHA:-} ]; then
echo "prompt: SHA cannot be retrieved, which could be related to rate limiting."
return 1
fi

if [ "${SHA+x}" = "${CURRENT_SHA+x}" ]; then
if [ "${SHA:-}" = "${CURRENT_SHA:-}" ]; then
echo "prompt: latest version already installed: $SHA"
return 0
fi
Expand Down
6 changes: 3 additions & 3 deletions uname/install-Darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ __prompt-install-darwin() {

local NVM_PATH=$(brew --prefix nvm)

if [ -d $NVM_PATH ]; then
if [ -f "$NVM_PATH/nvm.sh" ]; then
__prompt-success 'setting up nvm...'

export NVM_DIR="${HOME}/.nvm"
source "$NVM_PATH/nvm.sh"
nvm install --lts 1>/dev/null 2>&1
nvm use --lts --delete-prefix 1>/dev/null 2>&1
nvm use --lts --delete-prefix --silent 1>/dev/null 2>&1
fi

__prompt-success 'setting git credential helper to use the macOS keychain'
Expand Down

0 comments on commit 6147b37

Please sign in to comment.