Last active
April 10, 2025 09:50
-
-
Save creaktive/5528983 to your computer and use it in GitHub Desktop.
rainbarf sans tmux (to enable, "source rainbarf.zsh", under zsh)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment