oh-my-posh/src/init/omp.bash

27 lines
633 B
Bash
Raw Normal View History

2020-12-23 04:12:10 -08:00
export POSH_THEME=::CONFIG::
2021-03-02 11:37:31 -08:00
TIMER_START="/tmp/${USER}.start.$$"
PS0='$(::OMP:: --millis > $TIMER_START)'
2020-12-23 04:12:10 -08:00
function _update_ps1() {
2021-03-02 11:37:31 -08:00
omp_elapsed=-1
if [[ -f $TIMER_START ]]; then
omp_now=$(::OMP:: --millis)
omp_start_time=$(cat "$TIMER_START")
omp_elapsed=$(($omp_now-$omp_start_time))
rm $TIMER_START
fi
PS1="$(::OMP:: --config $POSH_THEME --error $? --execution-time $omp_elapsed --shell bash)"
2020-12-23 04:12:10 -08:00
}
if [ "$TERM" != "linux" ] && [ -x "$(command -v ::OMP::)" ]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
2021-03-02 11:37:31 -08:00
function runonexit() {
rm $TIMER_START
}
trap runonexit EXIT