diff options
author | Tharre <tharre3@gmail.com> | 2016-07-05 21:56:32 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2016-10-07 20:13:40 +0000 |
commit | e14ca42b2f706402f4dc2df95822e55802405ef8 (patch) | |
tree | eb90467836838b05c062b0183f8e741708466279 | |
parent | 7f9dc71e8b8dd2c9a366e25b952735f616aae49f (diff) | |
download | dotfiles-e14ca42b2f706402f4dc2df95822e55802405ef8.tar.gz dotfiles-e14ca42b2f706402f4dc2df95822e55802405ef8.tar.xz dotfiles-e14ca42b2f706402f4dc2df95822e55802405ef8.zip |
Add update functionality
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | shell/_zshrc | 24 |
2 files changed, 24 insertions, 1 deletions
@@ -1,2 +1,3 @@ *.pyc shell/_vim/.netrwhist +.updated 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 |