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,7 +1,8 @@
#!/bin/sh #!/bin/bash
installdeps() #
{ # myzsh installation script
#
#dependencies #dependencies
readonly deps="git zsh vim curl wget" readonly deps="git zsh vim curl wget"
@ -20,6 +21,7 @@ installdeps()
if [ $i -ne 0 ]; then if [ $i -ne 0 ]; then
#checking for system #checking for system
echo "[myzsh]: installing missing dependencies ($missingdeps)"
readonly systems="ubuntu arch raspbian solus" readonly systems="ubuntu arch raspbian solus"
issue="$(cat /etc/issue)" issue="$(cat /etc/issue)"
for item in $systems; do 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 exit 1
;; ;;
esac esac
fi fi
} #install
echo "[myzsh]: cleaning up previous installations."
installmyzsh()
{
rm -rf ~/.myzsh rm -rf ~/.myzsh
choice="null"
while [ $choice != "y" ] && [ $choice != "n" ]; do echo "[myzsh]: downloading repository."
read -p "[myzsh]: should i clone myzsh writeable? [y/n]" choice if [ -r ~/.ssh/id_rsa ]; then
if [ "$choice" == "y" ]; then
git clone git@socialg.it:david/myzsh.git ~/.myzsh git clone git@socialg.it:david/myzsh.git ~/.myzsh
else else
git clone https://socialg.it/david/myzsh.git ~/.myzsh git clone https://socialg.it/david/myzsh.git ~/.myzsh
fi 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 'ZSH="$HOME/.myzsh"' > ~/.zshrc
echo 'THEME="david"' >> ~/.zshrc echo 'THEME="david"' >> ~/.zshrc
echo 'plugins=(david)' >> ~/.zshrc echo 'plugins=(david)' >> ~/.zshrc
echo 'source $ZSH/myzsh.sh' >> ~/.zshrc echo 'source $ZSH/myzsh.sh' >> ~/.zshrc
echo "export PATH=$PATH" >> ~/.zshrc echo "export PATH=$PATH" >> ~/.zshrc
cat /etc/passwd | grep ~ | grep "/bin/zsh" echo "[myzsh]: successfully installed."
#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
exit 0 exit 0

View File

@ -3,6 +3,13 @@
# (runs at shell start) # (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 # check if there is canges to be pushed
cd $ZSH cd $ZSH
local SUBMODULE_SYNTAX='' local SUBMODULE_SYNTAX=''
@ -10,7 +17,8 @@ if [[ $POST_1_7_2_GIT -gt 0 ]]; then
SUBMODULE_SYNTAX="--ignore-submodules=dirty" SUBMODULE_SYNTAX="--ignore-submodules=dirty"
fi fi
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then 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 read choice
if [ $choice = "y" ]; then if [ $choice = "y" ]; then
git add **/*[^lastrun] git add **/*[^lastrun]