Utilize zstat for system stat calls for zshrc
This commit is contained in:
parent
204e945b6f
commit
cb16297268
2 changed files with 9 additions and 4 deletions
|
@ -1,6 +1,9 @@
|
||||||
#!/usr/bin/zsh
|
#!/usr/bin/zsh
|
||||||
|
|
||||||
zmodload zsh/datetime
|
zmodload zsh/datetime
|
||||||
|
# load the stat module but only with the `zstat` command
|
||||||
|
# leave `stat` to the system's stat command
|
||||||
|
zmodload -F zsh/stat b:zstat
|
||||||
|
|
||||||
autoload -Uz \
|
autoload -Uz \
|
||||||
colors \
|
colors \
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
|
|
||||||
COMPLETION_FILE="${ZSH_COMPLETIONS_DIR}/_chezmoi"
|
COMPLETION_FILE="${ZSH_COMPLETIONS_DIR}/_chezmoi"
|
||||||
if [ -r "$COMPLETION_FILE" ]; then
|
if [ -r "$COMPLETION_FILE" ]; then
|
||||||
COMPLETION_FILE_CTIME="$(stat -c %Z "$COMPLETION_FILE")"
|
zstat -H COMPLETION_FILE_STAT "$COMPLETION_FILE"
|
||||||
CHEZMOI_FILE_CTIME="$(stat -c %Z "${CHEZMOI_PATH}")"
|
zstat -H CHEZMOI_FILE_STAT "${CHEZMOI_PATH}"
|
||||||
|
|
||||||
if [ "$COMPLETION_FILE_CTIME" -ge "$CHEZMOI_FILE_CTIME" ]; then
|
if [ "${COMPLETION_FILE_STAT[ctime]}" -ge "${CHEZMOI_FILE_STAT[ctime]}" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -22,8 +22,10 @@
|
||||||
(
|
(
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
zstat -H LAST_PULL_STAT "$(chezmoi git rev-parse -- --show-toplevel)/.git/FETCH_HEAD"
|
||||||
|
|
||||||
# has the chezmoi repo been pulled in the last 24 hours?
|
# has the chezmoi repo been pulled in the last 24 hours?
|
||||||
if [ "$(date +%s -r "$(chezmoi git rev-parse -- --show-toplevel)/.git/FETCH_HEAD")" -gt $((EPOCHSECONDS-86400)) ]; then
|
if [ "${LAST_PULL_STAT[ctime]}" -gt $((EPOCHSECONDS-86400)) ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue