2013-01-18 14:21:37 +01:00
|
|
|
#!/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
|
2013-01-18 14:41:39 +01:00
|
|
|
/bin/zsh
|
2013-01-18 14:21:37 +01:00
|
|
|
else
|
|
|
|
echo "updating instead..."
|
|
|
|
cd ~/.myzsh
|
|
|
|
git pull origin master
|
2013-01-18 14:41:39 +01:00
|
|
|
/bin/zsh
|
2013-01-18 14:21:37 +01:00
|
|
|
cd -
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
installdeps
|
|
|
|
installmyzsh
|
2013-01-18 14:41:39 +01:00
|
|
|
/bin/zsh
|
2013-01-18 14:21:37 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
#end of script
|
|
|
|
exit 0
|