Add colorful PS4
PS4 can include functions, so when running in the LOG_COLORS=True mode provide a grey function line so that it's easier to visually distinguish the content from the location. Also make it so the main prompt chunks off all the common path, which means we can printf to 40 characters and have a pretty reasonable and readable PS4. Change-Id: I4a10a49db97d413349bcfceeb8c4164936fbcc40
This commit is contained in:
parent
0a2a7ae847
commit
646085d701
13
functions
13
functions
@ -30,6 +30,19 @@ function function_exists {
|
||||
declare -f -F $1 > /dev/null
|
||||
}
|
||||
|
||||
# short_source prints out the current location of the caller in a way
|
||||
# that strips redundant directories. This is useful for PS4 usage.
|
||||
function short_source {
|
||||
saveIFS=$IFS
|
||||
IFS=" "
|
||||
called=($(caller 0))
|
||||
IFS=$saveIFS
|
||||
file=${called[2]}
|
||||
file=${file#$RC_DIR/}
|
||||
printf "%-40s " "$file:${called[1]}:${called[0]}"
|
||||
}
|
||||
|
||||
|
||||
# Retrieve an image from a URL and upload into Glance.
|
||||
# Uses the following variables:
|
||||
#
|
||||
|
16
stackrc
16
stackrc
@ -14,9 +14,6 @@ unset LANGUAGE
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
# Make tracing more educational
|
||||
export PS4='+ ${BASH_SOURCE:-}:${FUNCNAME[0]:-}:L${LINENO:-}: '
|
||||
|
||||
# Find the other rc files
|
||||
RC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
|
||||
|
||||
@ -132,6 +129,16 @@ elif [[ -f $RC_DIR/.localrc.auto ]]; then
|
||||
source $RC_DIR/.localrc.auto
|
||||
fi
|
||||
|
||||
# Use color for logging output (only available if syslog is not used)
|
||||
LOG_COLOR=$(trueorfalse True LOG_COLOR)
|
||||
|
||||
# Make tracing more educational
|
||||
if [[ "$LOG_COLOR" == "True" ]]; then
|
||||
export PS4='+\[$(tput setaf 242)\]$(short_source)\[$(tput sgr0)\] '
|
||||
else
|
||||
export PS4='+ $(short_source): '
|
||||
fi
|
||||
|
||||
# Configure Identity API version: 2.0, 3
|
||||
IDENTITY_API_VERSION=${IDENTITY_API_VERSION:-2.0}
|
||||
|
||||
@ -785,9 +792,6 @@ SYSLOG=$(trueorfalse False SYSLOG)
|
||||
SYSLOG_HOST=${SYSLOG_HOST:-$HOST_IP}
|
||||
SYSLOG_PORT=${SYSLOG_PORT:-516}
|
||||
|
||||
# Use color for logging output (only available if syslog is not used)
|
||||
LOG_COLOR=$(trueorfalse True LOG_COLOR)
|
||||
|
||||
# Set global ``GIT_DEPTH=<number>`` to limit the history depth of the git clone
|
||||
# Set to 0 to disable shallow cloning
|
||||
GIT_DEPTH=${GIT_DEPTH:-0}
|
||||
|
@ -7,6 +7,22 @@
|
||||
# Warning: This script just for development purposes
|
||||
|
||||
set -o errexit
|
||||
|
||||
# short_source prints out the current location of the caller in a way
|
||||
# that strips redundant directories. This is useful for PS4
|
||||
# usage. Needed before we start tracing due to how we set
|
||||
# PS4. Normally we'd pick this up from stackrc, but that's not sourced
|
||||
# here.
|
||||
function short_source {
|
||||
saveIFS=$IFS
|
||||
IFS=" "
|
||||
called=($(caller 0))
|
||||
IFS=$saveIFS
|
||||
file=${called[2]}
|
||||
file=${file#$RC_DIR/}
|
||||
printf "%-40s " "$file:${called[1]}:${called[0]}"
|
||||
}
|
||||
|
||||
set -o xtrace
|
||||
|
||||
ACCOUNT_DIR=./accrc
|
||||
|
@ -11,7 +11,6 @@
|
||||
# - if USE_PYTHON3=True, PYTHON3_VERSION refers to a version already installed
|
||||
|
||||
set -o errexit
|
||||
set -o xtrace
|
||||
|
||||
# Keep track of the current directory
|
||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||
@ -23,6 +22,9 @@ cd $TOP_DIR
|
||||
# Import common functions
|
||||
source $TOP_DIR/stackrc
|
||||
|
||||
# don't start tracing until after we've sourced the world
|
||||
set -o xtrace
|
||||
|
||||
FILES=$TOP_DIR/files
|
||||
|
||||
PIP_GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py
|
||||
|
Loading…
Reference in New Issue
Block a user