From a3994cd962d89b90d48cc6acef94de22a857ab07 Mon Sep 17 00:00:00 2001 From: Alan Stebbens Date: Thu, 28 Aug 2014 11:51:01 -0700 Subject: [PATCH] aks: aesthetic touchups --- gitprompt.sh | 60 ++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/gitprompt.sh b/gitprompt.sh index 7242fdc..5a1dd93 100755 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -11,14 +11,14 @@ function git_prompt_dir() { # assume the gitstatus.py is in the same directory as this script # code thanks to http://stackoverflow.com/questions/59895 - if [ -z "${__GIT_PROMPT_DIR}" ]; then + if [ -z "$__GIT_PROMPT_DIR" ]; then local SOURCE="${BASH_SOURCE[0]}" - while [ -h "${SOURCE}" ]; do - local DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )" - SOURCE="$(readlink "${SOURCE}")" - [[ $SOURCE != /* ]] && SOURCE="${DIR}/${SOURCE}" + while [ -h "$SOURCE" ]; do + local DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" done - __GIT_PROMPT_DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )" + __GIT_PROMPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" fi } @@ -80,7 +80,7 @@ function git_prompt_config() # git-prompt-colors.sh -- sets the GIT_PROMPT color scheme, using names from prompt-colors.sh if gp_set_file_var __PROMPT_COLORS_SH prompt-colors.sh ; then - source "${__PROMPT_COLORS_SH}" # outsource the color defs + source "$__PROMPT_COLORS_SH" # outsource the color defs else echo 1>&2 "Cannot find prompt-colors.sh!" fi @@ -89,7 +89,7 @@ function git_prompt_config() # sitting in the same directory as this script if gp_set_file_var __GIT_PROMPT_COLORS_FILE git-prompt-colors.sh ; then - source "${__GIT_PROMPT_COLORS_FILE}" + source "$__GIT_PROMPT_COLORS_FILE" else echo 1>&2 "Cannot find git-prompt-colors.sh!" fi @@ -104,7 +104,7 @@ function git_prompt_config() # local Time12a="(\@))" local PathShort="\w" - if [[ -z "${GIT_PROMPT_START}" ]] ; then + if [[ -z "$GIT_PROMPT_START" ]] ; then if $_isroot; then PROMPT_START="$GIT_PROMPT_START_ROOT" else @@ -114,7 +114,7 @@ function git_prompt_config() PROMPT_START="$GIT_PROMPT_START" fi - if [[ -z "${GIT_PROMPT_END}" ]] ; then + if [[ -z "$GIT_PROMPT_END" ]] ; then if $_isroot; then PROMPT_END="$GIT_PROMPT_END_ROOT" else @@ -137,11 +137,11 @@ function git_prompt_config() else local ps="$LAST_COMMAND_INDICATOR" if [[ -n "$VIRTUAL_ENV" ]]; then - ps="$ps(${Blue}$(basename \"${VIRTUAL_ENV}\")${ResetColor}) " - elif [[ -n "${CONDA_DEFAULT_ENV}" ]]; then - ps="$ps(${Blue}$(basename \"${CONDA_DEFAULT_ENV}\")${ResetColor}) " + ps="$ps($Blue$(basename \"$VIRTUAL_ENV\")$ResetColor) " + elif [[ -n "$CONDA_DEFAULT_ENV" ]]; then + ps="$ps($Blue$(basename \"$CONDA_DEFAULT_ENV\")$ResetColor) " fi - EMPTY_PROMPT="$ps${PROMPT_START}$($prompt_callback)${PROMPT_END}" + EMPTY_PROMPT="$ps$PROMPT_START$($prompt_callback)$PROMPT_END" fi # fetch remote revisions every other $GIT_PROMPT_FETCH_TIMEOUT (default 5) minutes @@ -164,7 +164,7 @@ function setGitPrompt() { git_prompt_config local repo=`git rev-parse --show-toplevel 2> /dev/null` - if [[ ! -e "${repo}" ]]; then + if [[ ! -e "$repo" ]]; then PS1="$EMPTY_PROMPT" return fi @@ -189,7 +189,7 @@ function checkUpstream() { local GIT_PROMPT_FETCH_TIMEOUT git_prompt_config - local FETCH_HEAD="${repo}/.git/FETCH_HEAD" + local FETCH_HEAD="$repo/.git/FETCH_HEAD" # Fech repo if local is stale for more than $GIT_FETCH_TIMEOUT minutes if [[ ! -e "$FETCH_HEAD" || -e `find "$FETCH_HEAD" -mmin +$GIT_PROMPT_FETCH_TIMEOUT` ]] then @@ -215,7 +215,7 @@ function updatePrompt() { git_prompt_config local -a GitStatus - GitStatus=($("${__GIT_STATUS_CMD}" 2>/dev/null)) + GitStatus=($("$__GIT_STATUS_CMD" 2>/dev/null)) local GIT_BRANCH=${GitStatus[0]} local GIT_REMOTE=${GitStatus[1]} @@ -229,7 +229,7 @@ function updatePrompt() { local GIT_STASHED=${GitStatus[6]} local GIT_CLEAN=${GitStatus[7]} - if [[ -n "${GitStatus}" ]]; then + if [[ -n "$GitStatus" ]]; then local STATUS="${PROMPT_LEADING_SPACE}${GIT_PROMPT_PREFIX}${GIT_PROMPT_BRANCH}${GIT_BRANCH}${ResetColor}" # __add_status KIND VALEXPR INSERT @@ -238,26 +238,26 @@ function updatePrompt() { __chk_gitvar_status() { local v if [[ "x$2" == "x-n" ]] ; then - v="$2 \"\${GIT_$1}\"" + v="$2 \"\$GIT_$1\"" else - v="\${GIT_$1} $2" + v="\$GIT_$1 $2" fi if eval "test $v" ; then if [[ $# -lt 2 || "$3" != '-' ]]; then - __add_status "\${GIT_PROMPT_$1}\${GIT_$1}\${ResetColor}" + __add_status "\$GIT_PROMPT_$1\$GIT_$1\$ResetColor" else - __add_status "\${GIT_PROMPT_$1}\${ResetColor}" + __add_status "\$GIT_PROMPT_$1\$ResetColor" fi fi } __add_gitvar_status() { - __add_status "\${GIT_PROMPT_$1}\${GIT_$1}\${ResetColor}" + __add_status "\$GIT_PROMPT_$1\$GIT_$1\$ResetColor" } # __add_status SOMETEXT __add_status() { - eval "STATUS=\"${STATUS}$1\"" + eval "STATUS=\"$STATUS$1\"" } __chk_gitvar_status 'REMOTE' '-n' @@ -268,15 +268,15 @@ function updatePrompt() { __chk_gitvar_status 'UNTRACKED' '-ne 0' __chk_gitvar_status 'STASHED' '-ne 0' __chk_gitvar_status 'CLEAN' '-eq 1' - - __add_status "${ResetColor}$GIT_PROMPT_SUFFIX" + __add_status "$ResetColor$GIT_PROMPT_SUFFIX" - PS1="${LAST_COMMAND_INDICATOR}${PROMPT_START}$($prompt_callback)${STATUS}${PROMPT_END}" - if [[ -n "${VIRTUAL_ENV}" ]]; then - PS1="(${Blue}$(basename \"$VIRTUAL_ENV\")${ResetColor}) ${PS1}" + PS1="$LAST_COMMAND_INDICATOR$PROMPT_START$($prompt_callback)$STATUS$PROMPT_END" + if [[ -n "$VIRTUAL_ENV" ]]; then + PS1="($Blue$(basename \"$VIRTUAL_ENV\")$ResetColor) $PS1" fi - if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then - PS1="(${Blue}$(basename \"$CONDA_DEFAULT_ENV\")${ResetColor}) ${PS1}" + if [[ -n "$CONDA_DEFAULT_ENV" ]]; then + PS1="($Blue$(basename \"$CONDA_DEFAULT_ENV\")$ResetColor) $PS1" fi else