Compare commits

..

2 Commits

Author SHA1 Message Date
Anton Zadvorny
70f3600de3 Fix formatting 2019-08-11 18:47:35 +03:00
Anton Zadvorny
969e0c42f7 Add zplug auto update plugin 2019-08-11 18:47:25 +03:00
3 changed files with 46 additions and 4 deletions

View File

@ -17,8 +17,8 @@ if [[ $lang ]]; then
asdf plugin-update $lng
fi
for version in $(asdf list-all $lng | sort -nrk1,1 | eval "fzf ${FZF_DEFAULT_OPTS} -m --header='[asdf:${lng}:install]'")
do asdf install $lng $version
for version in $(asdf list-all $lng | sort -nrk1,1 | eval "fzf ${FZF_DEFAULT_OPTS} -m --header='[asdf:${lng}:install]'"); do
asdf install $lng $version
done
done
fi

View File

@ -0,0 +1,41 @@
_zplug-check-interval() {
now=$(date +%s)
if [ -f "${1}" ]; then
last_update=$(cat "${1}")
else
last_update=0
fi
interval=$(expr ${now} - ${last_update})
echo "${interval}"
}
_zplug-check-for-updates() {
if [ -z "${ZPLUG_PLUGIN_UPDATE_DAYS}" ]; then
ZPLUG_PLUGIN_UPDATE_DAYS=14
fi
if [ -z "${ZPLUG_PLUGIN_UPDATE_FILE}" ]; then
ZPLUG_PLUGIN_UPDATE_FILE="${ZPLUG_HOME:-}/.zplug_plugin_lastupdate"
fi
local day_seconds=$(expr 24 \* 60 \* 60)
local plugins_seconds=$(expr ${day_seconds} \* ${ZPLUG_PLUGIN_UPDATE_DAYS})
local last_plugin=$(_zplug-check-interval ${ZPLUG_PLUGIN_UPDATE_FILE})
if [ ${last_plugin} -gt ${plugins_seconds} ]; then
echo "It has been $(expr ${last_plugin} / $day_seconds) days since your zplug plugins were updated"
zplug update
date +%s >! ${ZPLUG_PLUGIN_UPDATE_FILE}
zplug clean --force
fi
}
zmodload zsh/system
lockfile=${ZPLUG_HOME:-~}/.zplug_autoupdate_lock
touch $lockfile
if ! which zsystem &> /dev/null || zsystem flock -t 1 $lockfile; then
_zplug-check-for-updates
command rm -f $lockfile
fi

View File

@ -37,8 +37,9 @@ zplug "plugins/asdf", from:oh-my-zsh
zplug "zsh-users/zsh-completions"
zplug "zsh-users/zsh-syntax-highlighting", defer:2
zplug "~/.zsh/cmd", from:local, use:'(*).sh', as:command, rename-to:'$1'
zplug "~/.zsh/themes", from:local, use:cheetah.zsh-theme, as:theme
zplug "~/.zsh/plugins", from:local
zplug "~/.zsh/cmd", from:local, use:'(*).sh', as:command, rename-to:'$1'
zplug "~/.zsh/themes", from:local, use:cheetah.zsh-theme, as:theme
if [[ $OSTYPE == *darwin* ]]; then
zplug "plugins/osx", from:oh-my-zsh