diff --git a/.prompt b/.prompt index e8fa955..da25c66 100644 --- a/.prompt +++ b/.prompt @@ -35,11 +35,11 @@ __get_cmd_time() { local SECS=$((10#0$(TZ=UTC printf '%(%S)T' $CMD_TIME))) # Choose whether or not to print hours minutes and seconds - [[ $CMD_TIME -ge 31536000 ]] && printf '%sy ' ${YEAR:-0} - [[ $CMD_TIME -ge 86400 ]] && printf '%sd ' ${DAYS:-0} - [[ $CMD_TIME -ge 3600 ]] && printf '%sh ' ${HOUR:-0} - [[ $CMD_TIME -ge 60 ]] && printf '%sm ' ${MINS:-0} - [[ $CMD_TIME -ge 1 ]] && printf '%ss ' ${SECS:-0} + [[ $CMD_TIME -ge 31536000 ]] && printf '%sy ' ${YEAR} + [[ $CMD_TIME -ge 86400 ]] && printf '%sd ' ${DAYS} + [[ $CMD_TIME -ge 3600 ]] && printf '%sh ' ${HOUR} + [[ $CMD_TIME -ge 60 ]] && printf '%sm ' ${MINS} + [[ $CMD_TIME -ge 1 ]] && printf '%ss ' ${SECS} # If you want to have a limit uncomment the next line and replace somenum with # the minimum microseconds # [[ $CMD_US -ge somenum ]] && @@ -102,8 +102,8 @@ __ssh() { # 4 chars from startand 4 chars from end local SRV_IP_CUT="${_CYN}${SRV_IP}" [[ ${#SRV_IP} -gt 8 ]] && local SRV_IP_CUT="${_CYN}${SRV_IP:0:4}${_WHT}*${_CYN}${SRV_IP: -4}" - local RET="${_GRN}${_BLU}[${SRV_IP_CUT}${_PRP}${_BLD}:${_NON}${_CYN}${SRV_PORT}${_BLU}]${_NON}" - printf '%s' "$RET" + + printf '%s' "${_GRN}${_BLU}[${SRV_IP_CUT}${_PRP}${_BLD}:${_NON}${_CYN}${SRV_PORT}${_BLU}]${_NON}" } __prompt() { @@ -111,7 +111,8 @@ __prompt() { local PLC=(${PIPESTATUS[@]}) # Reset time when prompt was first displayed after command - if [[ ${INC_TIME:-1} != 0 ]]; then + # this contributes to the 40 microsecond difference in $CMD_US and the actual time it took + if [[ "$INC_TIME" != 0 ]]; then PROMPT_RT="$EPOCHREALTIME" INC_TIME=0 fi @@ -128,9 +129,10 @@ __prompt() { CMD_US="$(($PROMPT_RT1M-$LAST_RT1M))" - # Subtract and divide by 1 million to get a more accurate difference - CMD_TIME="$((CMD_US/1000000))" - CMD_TIME="${CMD_TIME:-0}" + CMD_TIME=0 + + # Remove last 6 chars, simulating dividing by 1 million to get a more accurate difference + [[ ${#CMD_US} -lt 6 ]] || CMD_TIME="${CMD_US::-6}" [[ ${#CMD_US} -lt 6 ]] || CMD_US="${CMD_US: -6}" CMD_US="$((10#0$CMD_US))" @@ -143,6 +145,7 @@ __prompt() { [[ "$SSH_CONNECTION" ]] && local SSH="$(__ssh) " # [INT], [4], etc. + local i for i in ${PLC[@]}; do if [[ $i > 0 ]]; then local SIG="$(printf '%s[%s%s%s] ' "$_BLU" "$_RED" "$(__sig ${PLC[@]})" "$_BLU")"