aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2017-10-18 02:34:20 +0300
committerGitHub <noreply@github.com>2017-10-18 02:34:20 +0300
commit37a27463b8d6d61087464926719b1c65c2b9cf76 (patch)
tree04401f5b1b8ccc9dd42528f713195eacb3d3f781
parentaef54bfbaa941e2c59be2394fd2ecef26163c526 (diff)
parent20b69370a679b6c3a8a2084615206d78fe0ae542 (diff)
Merge pull request #647 from sbutler2901/master
OSX bug fix for prompt_public_ip
-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