autopush by david@ghost
This commit is contained in:
parent
fcd0c174a9
commit
62d188a135
65
install.sh
65
install.sh
|
@ -1,7 +1,8 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
installdeps()
|
||||
{
|
||||
#
|
||||
# myzsh installation script
|
||||
#
|
||||
|
||||
#dependencies
|
||||
readonly deps="git zsh vim curl wget"
|
||||
|
@ -20,6 +21,7 @@ installdeps()
|
|||
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
|
||||
|
@ -44,65 +46,36 @@ installdeps()
|
|||
;;
|
||||
|
||||
?)
|
||||
echo "[myzsh]: i cannot install dependencies. unknown system."
|
||||
echo "[myzsh]: i cannot install dependencies. goodbye."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
installmyzsh()
|
||||
{
|
||||
|
||||
#install
|
||||
echo "[myzsh]: cleaning up previous installations."
|
||||
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
|
||||
|
||||
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
|
||||
done
|
||||
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
|
||||
|
||||
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
|
||||
echo "[myzsh]: successfully installed."
|
||||
|
||||
|
||||
}
|
||||
|
||||
#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
|
||||
exit 0
|
||||
|
|
10
myzsh.sh
10
myzsh.sh
|
@ -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]
|
||||
|
|
Reference in New Issue