david/myzsh
david
/
myzsh
Archived
1
0
Fork 0

autopush by david@ghost

This commit is contained in:
david 2017-10-03 23:53:15 +02:00
parent fcd0c174a9
commit 62d188a135
2 changed files with 79 additions and 98 deletions

View File

@ -1,108 +1,81 @@
#!/bin/sh
#!/bin/bash
installdeps()
{
#
# myzsh installation script
#
#dependencies
readonly deps="git zsh vim curl wget"
#dependencies
readonly deps="git zsh vim curl wget"
#check for dependencies
missingdeps=""
i=0
for dep in $deps; do
if [ $(command -v $dep > /dev/null; echo $?) -ne "0" ]; then
missingdeps="$missingdeps $dep"
i=$((i+1))
#check for dependencies
missingdeps=""
i=0
for dep in $deps; do
if [ $(command -v $dep > /dev/null; echo $?) -ne "0" ]; then
missingdeps="$missingdeps $dep"
i=$((i+1))
fi
done
#try to install unmet dependencies
if [ $i -ne 0 ]; then
#checking for system
echo "[myzsh]: installing missing dependencies ($missingdeps)"
readonly systems="ubuntu arch raspbian solus"
issue="$(cat /etc/issue)"
for item in $systems; do
echo $issue | grep -i $item
if [ $? -eq 0 ]; then
system=$item
fi
done
#try to install unmet dependencies
if [ $i -ne 0 ]; then
case $system in
ubuntu)
sudo apt-get update && sudo apt-get install -y $missingdeps
;;
arch)
sudo pacman -Su $missingdeps
;;
raspbian)
sudo apt-get update && sudo apt-get install -y $missingdeps
;;
solus)
sudo eopkg update-repo && sudo eopkg install $missingdeps
;;
#checking for system
readonly systems="ubuntu arch raspbian solus"
issue="$(cat /etc/issue)"
for item in $systems; do
echo $issue | grep -i $item
if [ $? -eq 0 ]; then
system=$item
fi
done
?)
echo "[myzsh]: i cannot install dependencies. goodbye."
exit 1
;;
esac
case $system in
ubuntu)
sudo apt-get update && sudo apt-get install -y $missingdeps
;;
arch)
sudo pacman -Su $missingdeps
;;
raspbian)
sudo apt-get update && sudo apt-get install -y $missingdeps
;;
solus)
sudo eopkg update-repo && sudo eopkg install $missingdeps
;;
?)
echo "[myzsh]: i cannot install dependencies. unknown system."
exit 1
;;
esac
fi
}
installmyzsh()
{
rm -rf ~/.myzsh
choice="null"
while [ $choice != "y" ] && [ $choice != "n" ]; do
read -p "[myzsh]: should i clone myzsh writeable? [y/n]" choice
if [ "$choice" == "y" ]; then
git clone git@socialg.it:david/myzsh.git ~/.myzsh
else
git clone https://socialg.it/david/myzsh.git ~/.myzsh
fi
done
echo 'ZSH="$HOME/.myzsh"' > ~/.zshrc
echo 'THEME="david"' >> ~/.zshrc
echo 'plugins=(david)' >> ~/.zshrc
echo 'source $ZSH/myzsh.sh' >> ~/.zshrc
echo "export PATH=$PATH" >> ~/.zshrc
cat /etc/passwd | grep ~ | grep "/bin/zsh"
#set default shell if not set already
if [ $? -eq 1 ]; then
read -p "[myzsh]: time to change your default shell to /bin/zsh"
sudo vim /etc/passwd
fi
}
#start of script
if [ -d ~/.myzsh ]; then
choice="null"
echo "[myzsh]: it seems i have already been set up."
read -p "[myzsh]: should i cleanup & reinstall? [y/n]" choice
if [ "$choice" == "y" ]; then
installdeps
installmyzsh
else
echo "[myzsh]: updating instead."
cd ~/.myzsh
git pull origin master
cd -
fi
else
installdeps
installmyzsh
fi
#end of script
#install
echo "[myzsh]: cleaning up previous installations."
rm -rf ~/.myzsh
echo "[myzsh]: downloading repository."
if [ -r ~/.ssh/id_rsa ]; then
git clone git@socialg.it:david/myzsh.git ~/.myzsh
else
git clone https://socialg.it/david/myzsh.git ~/.myzsh
fi
if [ $? -ne 0 ]; then
echo "[myzsh]: i cannot clone repository. goodbye."
exit 1
fi
#config
echo "[myzsh]: setting up config."
echo 'ZSH="$HOME/.myzsh"' > ~/.zshrc
echo 'THEME="david"' >> ~/.zshrc
echo 'plugins=(david)' >> ~/.zshrc
echo 'source $ZSH/myzsh.sh' >> ~/.zshrc
echo "export PATH=$PATH" >> ~/.zshrc
echo "[myzsh]: successfully installed."
exit 0

View File

@ -3,6 +3,13 @@
# (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=''
@ -10,7 +17,8 @@ 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 "[myzsh]: local myzsh repo is dirty. commit and push changes? [y/n] \c"
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]