summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2016-07-05 21:56:32 +0200
committerTharre <tharre3@gmail.com>2016-10-07 20:13:40 +0000
commite14ca42b2f706402f4dc2df95822e55802405ef8 (patch)
treeeb90467836838b05c062b0183f8e741708466279 /shell
parent7f9dc71e8b8dd2c9a366e25b952735f616aae49f (diff)
downloaddotfiles-e14ca42b2f706402f4dc2df95822e55802405ef8.tar.gz
dotfiles-e14ca42b2f706402f4dc2df95822e55802405ef8.tar.xz
dotfiles-e14ca42b2f706402f4dc2df95822e55802405ef8.zip
Add update functionality
Diffstat (limited to 'shell')
-rw-r--r--shell/_zshrc24
1 files changed, 23 insertions, 1 deletions
diff --git a/shell/_zshrc b/shell/_zshrc
index 8884395..9d84fed 100644
--- a/shell/_zshrc
+++ b/shell/_zshrc
@@ -15,7 +15,7 @@ ZSH_THEME="custom"
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
-# DISABLE_AUTO_UPDATE="true"
+DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
@@ -108,6 +108,26 @@ function 256color_test {
done )
}
+# update
+function update_dotfiles() {
+ dotfiles="$HOME/dotfiles"
+ epoch_file="$dotfiles/.updated"
+ epoch_curr=$(date +'%s')
+ [ -e "$epoch_file" ] && epoch_old=$(<"$epoch_file")
+ epoch_diff=$(($epoch_curr - ${epoch_old:-0}))
+ max_time=$((60 * 60 * 24 * 7))
+
+ if [ $(($epoch_diff / $max_time)) -ne 0 ]; then
+ echo "Updating dotfiles ..."
+
+ cd "$dotfiles"
+ git pull --rebase --stat origin master
+ echo $epoch_curr > "$epoch_file"
+
+ echo "Finished."
+ fi
+}
+
## PATH
export PATH=$PATH:$HOME/bin
@@ -137,6 +157,8 @@ setopt EXTENDED_GLOB
HISTSIZE=100000000
## startup
+update_dotfiles
+
if type "archey" > /dev/null; then
archey # nice system information and arch logo
fi