fix(bash): fallback TIMER_START to HOME

resolves #802
This commit is contained in:
Jan De Dobbeleer 2021-06-12 21:39:52 +02:00 committed by Jan De Dobbeleer
parent 3ec46f480b
commit 08c0d9a957

View file

@ -4,14 +4,19 @@ export CONDA_PROMPT_MODIFIER=false
TIMER_START="/tmp/${USER}.start.$$"
PS0='$(::OMP:: --millis > $TIMER_START)'
# some environments don't have the filesystem we'd expect
if [[ ! -d "/tmp" ]]; then
TIMER_START="${HOME}/.${USER}.start.$$"
fi
PS0='$(::OMP:: --millis > $TIMER_START)'
function _omp_hook() {
local ret=$?
omp_stack_count=$((${#DIRSTACK[@]} - 1))
omp_elapsed=-1
if [[ -f $TIMER_START ]]; then
if [[ -f "$TIMER_START" ]]; then
omp_now=$(::OMP:: --millis)
omp_start_time=$(cat "$TIMER_START")
omp_elapsed=$((omp_now-omp_start_time))