2017-10-03 21:40:47 +02:00
|
|
|
#
|
|
|
|
# Main myzsh script
|
|
|
|
# (runs at shell start)
|
|
|
|
#
|
|
|
|
|
2017-10-03 23:53:15 +02:00
|
|
|
# check for default shell
|
|
|
|
cat /etc/passwd | grep ~ | grep "/bin/zsh" > /dev/null
|
2018-02-19 23:46:27 +01:00
|
|
|
if [ $? -eq 1 ] && [ $(uname) != "Darwin" ]; then
|
2017-10-03 23:53:15 +02:00
|
|
|
echo "[myzsh]: you should set me as your default shell."
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2017-10-04 00:30:50 +02:00
|
|
|
# check if there are canges to be pushed
|
2013-01-18 23:27:24 +01:00
|
|
|
cd $ZSH
|
2017-10-04 00:29:30 +02:00
|
|
|
if [[ -n $(git status --porcelain) ]]; then
|
2017-10-03 23:53:15 +02:00
|
|
|
echo -n "[myzsh]: local myzsh repo is dirty. commit and push changes? [y/n]"
|
2013-01-18 23:27:24 +01:00
|
|
|
read choice
|
2017-10-04 00:06:31 +02:00
|
|
|
if [ $choice ]; then
|
|
|
|
if [ "$choice" = "y" ]; then
|
|
|
|
git add **/*[^lastrun]
|
|
|
|
git commit -am "autopush by $(whoami)@$(hostname)"
|
|
|
|
git push origin master
|
|
|
|
fi
|
2013-01-18 23:27:24 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
cd - > /dev/null
|
|
|
|
|
|
|
|
|
2017-10-03 21:40:47 +02:00
|
|
|
# force myzsh update (every 30 days)
|
2013-01-18 16:42:30 +01:00
|
|
|
timestamp=$(date +%s)
|
2013-01-18 16:50:33 +01:00
|
|
|
if [ -r $ZSH/lastrun ];then
|
|
|
|
lastrun=$(cat $ZSH/lastrun)
|
2017-10-03 21:40:47 +02:00
|
|
|
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
|
2013-06-20 20:11:09 +02:00
|
|
|
git pull origin master
|
2017-10-03 23:54:53 +02:00
|
|
|
cd - > /dev/null
|
2013-06-20 13:47:43 +02:00
|
|
|
echo $timestamp > $ZSH/lastrun
|
2013-01-18 16:42:30 +01:00
|
|
|
fi
|
2013-01-18 16:50:33 +01:00
|
|
|
else
|
|
|
|
echo $timestamp > $ZSH/lastrun
|
2013-01-18 16:42:30 +01:00
|
|
|
fi
|
2013-01-18 16:16:57 +01:00
|
|
|
|
|
|
|
|
2013-01-17 14:59:21 +01:00
|
|
|
# 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
|