david/myzsh
david
/
myzsh
Archived
1
0
Fork 0

added install script

This commit is contained in:
david 2013-01-18 14:21:37 +01:00
parent 4cb1afcfab
commit ef22235247
1 changed files with 104 additions and 0 deletions

104
install.sh Executable file
View File

@ -0,0 +1,104 @@
#!/bin/sh
installdeps()
{
#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++))
fi
done
#try to install unmet dependencies
if [ $i -ne 0 ]; then
#checking for system
readonly systems="ubuntu arch"
issue="$(cat /etc/issue)"
for item in $systems; do
echo $issue | grep -i $item
if [ $? -eq 0 ]; then
system=$item
fi
done
case $system in
ubuntu)
sudo apt-get update && sudo apt-get install -y $missingdeps
;;
arch)
sudo pacman -Su $missingdeps
;;
?)
echo "unknown system. could not install anything"
;;
esac
fi
}
installmyzsh()
{
rm -rf ~/.myzsh
choice="null"
while [ $choice != "y" ] && [ $choice != "n" ]; do
echo ""
read -p "should i clone myzsh writeable? [y/n]" choice
if [ $choice = "y" ]; then
git clone git@bitbucket.org:beyondthewall/myzsh.git ~/.myzsh
else
git clone https://bitbucket.org/beyondthewall/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
read -p "now modify your ~/.zshrc to your needs"
vim ~/.zshrc
cat /etc/passwd | grep ~ | grep "/bin/zsh"
#set default shell if not set already
if [ $? -eq 1 ]; then
read -p "time to change your default shell to /bin/zsh"
sudo vim /etc/passwd
fi
}
#start of script
if [ -d ~/.myzsh ]; then
echo ""
echo "skipping myzsh installation. it is already there."
echo ""
read -p "do you want to cleanup and reinstall? [y/n]" choice
if [ $choice = "y" ]; then
installdeps
installmyzsh
else
echo "updating instead..."
cd ~/.myzsh
git pull origin master
cd -
fi
else
installdeps
installmyzsh
fi
#end of script
exit 0