# abort if already under tmux [[ -n $TMUX_PANE ]] && return # zsh-specific includes zmodload -i zsh/datetime zmodload -i zsh/stat # place to store the chart RAINBARF_OUT=~/.rainbarf.out # update period, in seconds TMOUT=30 # update the stored chart, avoiding running multiple rainbarf instances rainbarf_update () { # check if non-existent or outdated if [[ \ (! -e $RAINBARF_OUT) \ || ($(stat +mtime $RAINBARF_OUT) -lt $(( $EPOCHSECONDS - $TMOUT ))) \ ]]; then # rainbarf options should go to ~/.rainbarf.conf rainbarf --notmux > $RAINBARF_OUT fi } rainbarf_update # in-place prompt update hook TRAPALRM () { rainbarf_update zle reset-prompt } # insert rainbarf chart into prompt setopt PROMPT_SUBST PS1="\$(cat $RAINBARF_OUT) $PS1"