69 lines
1.5 KiB
Bash
69 lines
1.5 KiB
Bash
#
|
|
# Main myzsh script
|
|
# (runs at shell start)
|
|
#
|
|
|
|
# check for default shell
|
|
cat /etc/passwd | grep ~ | grep "/bin/zsh" > /dev/null
|
|
if [ $? -eq 1 ]; then
|
|
echo "[myzsh]: you should set me as your default shell."
|
|
fi
|
|
|
|
|
|
# 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
|
|
choice="null"
|
|
echo -n "[myzsh]: local myzsh repo is dirty. commit and push changes? [y/n]"
|
|
read choice
|
|
if [ $choice = "y" ]; then
|
|
git add **/*[^lastrun]
|
|
git commit -am "autopush by $(whoami)@$(hostname)"
|
|
git push origin master
|
|
fi
|
|
fi
|
|
cd - > /dev/null
|
|
|
|
|
|
# force myzsh update (every 30 days)
|
|
timestamp=$(date +%s)
|
|
if [ -r $ZSH/lastrun ];then
|
|
lastrun=$(cat $ZSH/lastrun)
|
|
if [ $((lastrun+2592000)) -le $timestamp ]; then
|
|
echo "[myzsh]: i have not been updated for at least 30 days."
|
|
echo "[myzsh]: forcing update now."
|
|
cd $ZSH
|
|
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
|