Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout cache after 1 hour #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion zshrc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
export __GIT_PROMPT_DIR=${0:A:h}

export GIT_PROMPT_EXECUTABLE=${GIT_PROMPT_EXECUTABLE:-"python"}
export GIT_PROMPT_CACHE_TIME=3600
export GIT_PROMPT_VALID_UNTIL=$(( `date +%s` + $GIT_PROMPT_CACHE_TIME ))

# Initialize colors.
autoload -U colors
Expand All @@ -30,7 +32,7 @@ function preexec_update_git_vars() {
}

function precmd_update_git_vars() {
if [ -n "$__EXECUTED_GIT_COMMAND" ] || [ ! -n "$ZSH_THEME_GIT_PROMPT_CACHE" ]; then
if [ -n "$__EXECUTED_GIT_COMMAND" ] || [ ! -n "$ZSH_THEME_GIT_PROMPT_CACHE" ] || (( $(date +%s) > $GIT_PROMPT_VALID_UNTIL )); then
update_current_git_vars
unset __EXECUTED_GIT_COMMAND
fi
Expand All @@ -42,6 +44,7 @@ function chpwd_update_git_vars() {

function update_current_git_vars() {
unset __CURRENT_GIT_STATUS
export GIT_PROMPT_VALID_UNTIL=$(( `date +%s` + $GIT_PROMPT_CACHE_TIME ))

if [[ "$GIT_PROMPT_EXECUTABLE" == "python" ]]; then
local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py"
Expand Down