david/myzsh
david
/
myzsh
Archived
1
0
Fork 0
This repository has been archived on 2020-12-06. You can view files and clone it, but cannot push or open issues or pull requests.
myzsh/myzsh.sh

72 lines
1.9 KiB
Bash

# check if there is canges to be pushed
cd $ZSH
local SUBMODULE_SYNTAX=''
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
fi
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
echo -e "do you want to push myzsh changes? [y/n] \c"
read choice
if [ $choice = "y" ]; then
git add **/*[^lastrun]
git commit -am "pushzshconfig $(date "+%d.%m.%Y %H:%M")"
git push origin master
fi
fi
cd - > /dev/null
# run myzsh update (every 7 days)
timestamp=$(date +%s)
if [ -r $ZSH/lastrun ];then
lastrun=$(cat $ZSH/lastrun)
if [ $((lastrun+604800)) -le $timestamp ]; then
cd $ZSH; git remote -v | grep -i bitbucket >> /dev/null
if [ $? -eq 0 ]; then
choice=""
echo "myzsh moved to github.com. unfortunately your"
echo "myzsh repository still points to bitbucket.org."
echo -e "do you want to fix this? [y/n] \c"
read choice
if [ $choice = "y" ]; then
git remote -v | grep @ >> /dev/null
if [ $? -eq 0 ]; then
git remote rm origin
git remote add origin git@github.com:beyondthewall/myzsh.git
else
git remote rm origin
git remote add origin https://github.com/beyondthewall/myzsh.git
fi
fi
fi
echo "running update of myzsh now.."
git pull origin master
cd -
echo $timestamp > $ZSH/lastrun
fi
else
echo $timestamp > $ZSH/lastrun
fi
# load core
for config_file ($ZSH/core/*.zsh); do
source $config_file
done
# load plugins
for plugin ($plugins); do
if [ -f $ZSH/plugins/$plugin.zsh ]; then
source "$ZSH/plugins/$plugin.zsh"
fi
done
# load theme
if [ -f $ZSH/themes/$THEME.zsh ]; then
source "$ZSH/themes/$THEME.zsh"
fi
# load completion
autoload -U compinit
compinit -i