-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
omp.bash
30 lines (22 loc) · 747 Bytes
/
omp.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
export POSH_THEME=::CONFIG::
TIMER_START="/tmp/${USER}.start.$$"
PS0='$(::OMP:: --millis > $TIMER_START)'
function _omp_hook() {
local ret=$?
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 --shell bash --error $ret --execution-time $omp_elapsed)"
return $ret
}
if [ "$TERM" != "linux" ] && [ -x "$(command -v ::OMP::)" ] && ! [[ "$PROMPT_COMMAND" =~ "_omp_hook" ]]; then
PROMPT_COMMAND="_omp_hook; $PROMPT_COMMAND"
fi
function _omp_runonexit() {
[[ -f $TIMER_START ]] && rm "$TIMER_START"
}
trap _omp_runonexit EXIT