summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsbutler2901 <sbsoftware@protonmail.com>2017-10-12 09:02:45 +0300
committersbutler2901 <sbsoftware@protonmail.com>2017-10-12 09:02:45 +0300
commit20b69370a679b6c3a8a2084615206d78fe0ae542 (patch)
tree4ed4b6e5f6ba12a1352c2c20f227ee801ae25a36
parent834b6735fa8867b5447f79f94915835cb871a08a (diff)
Bug fix for prompt_public_ip. The OSX date command does not have the -r option for getting the last modification time of a file. The stat command is being used instead
-rwxr-xr-xpowerlevel9k.zsh-theme6
1 files changed, 5 insertions, 1 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 97d13a3c..f6646c63 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -507,7 +507,11 @@ prompt_public_ip() {
if [[ -f $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then
typeset -i timediff
# if saved IP is more than
- timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s)))
+ if [[ "$OS" == "OSX" ]]; then
+ timediff=$(($(date +%s) - $(stat -f "%m" $POWERLEVEL9K_PUBLIC_IP_FILE)))
+ else
+ timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s)))
+ fi
[[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMEOUT ]] && refresh_ip=true
# If tmp file is empty get a fresh IP
[[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=true