summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrjorgenson <rjorgenson@gmail.com>2017-01-04 02:55:33 +0300
committerrjorgenson <rjorgenson@gmail.com>2017-01-04 02:55:33 +0300
commit6c46410a2f300a015254b3662b06ab572815c9f3 (patch)
tree3f08df02c7f5e655348d862da298b92a99dd7dff
parentf9bb7a2e949593287b2fc72ef06115d517dd8c4f (diff)
updated some comments
changed some offline behavior
-rwxr-xr-xpowerlevel9k.zsh-theme11
1 files changed, 5 insertions, 6 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 3693f02d..22e61d62 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -436,11 +436,10 @@ prompt_public_ip() {
local refresh_ip=false
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)))
- [[ $timediff -gt '500' ]] && refresh_ip=true
- # this will run the IP refresh with each new prompt while disconnected
- # but will get a new IP immediately once reconnected rather than waiting
- # for the timeout, not sure if this is ideal behavior or not
+ [[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMOUT ]] && refresh_ip=true
+ # If tmp file is empty get a fresh IP
[[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=true
else
touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=true
@@ -461,8 +460,8 @@ prompt_public_ip() {
fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)"
fi
- # write IP to tmp file or touch tmp file if an IP was not retrieved
- [[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE || touch $POWERLEVEL9K_PUBLIC_IP_FILE
+ # write IP to tmp file or clear tmp file if an IP was not retrieved
+ [[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE || echo "" > $POWERLEVEL9K_PUBLIC_IP_FILE
fi
# read public IP saved to tmp file