david/myzsh
david
/
myzsh
Archived
1
0
Fork 0
This repository has been archived on 2020-12-06. You can view files and clone it, but cannot push or open issues or pull requests.
myzsh/install.sh

109 lines
2.5 KiB
Bash
Raw Normal View History

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"
2013-01-23 11:46:40 +01:00
i=$((i+1))
2013-01-18 14:21:37 +01:00
fi
done
#try to install unmet dependencies
if [ $i -ne 0 ]; then
#checking for system
2017-10-03 22:16:09 +02:00
readonly systems="ubuntu arch raspbian solus"
2013-01-18 14:21:37 +01:00
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
;;
2017-10-03 22:16:09 +02:00
raspbian)
sudo apt-get update && sudo apt-get install -y $missingdeps
;;
solus)
sudo eopkg update-repo && sudo eopkg install $missingdeps
;;
2013-01-18 14:21:37 +01:00
?)
2017-10-03 22:16:09 +02:00
echo "[myzsh]: i cannot install dependencies. unknown system."
exit 1
2013-01-18 14:21:37 +01:00
;;
esac
fi
}
installmyzsh()
{
rm -rf ~/.myzsh
choice="null"
while [ $choice != "y" ] && [ $choice != "n" ]; do
2017-10-03 22:16:09 +02:00
read -p "[myzsh]: should i clone myzsh writeable? [y/n]" choice
2017-10-03 22:45:55 +02:00
if [ "$choice" == "y" ]; then
2016-10-02 08:46:44 +02:00
git clone git@socialg.it:david/myzsh.git ~/.myzsh
2013-01-18 14:21:37 +01:00
else
2016-10-02 08:46:44 +02:00
git clone https://socialg.it/david/myzsh.git ~/.myzsh
2013-01-18 14:21:37 +01:00
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
2017-10-03 22:16:09 +02:00
read -p "[myzsh]: time to change your default shell to /bin/zsh"
2013-01-18 14:21:37 +01:00
sudo vim /etc/passwd
fi
}
#start of script
if [ -d ~/.myzsh ]; then
2017-10-03 22:41:50 +02:00
choice="null"
2017-10-03 22:27:42 +02:00
echo "[myzsh]: it seems i have already been set up."
2017-10-03 22:33:57 +02:00
read -p "[myzsh]: should i cleanup & reinstall? [y/n]" choice
2017-10-03 22:45:55 +02:00
if [ "$choice" == "y" ]; then
2013-01-18 14:21:37 +01:00
installdeps
installmyzsh
else
2017-10-03 22:16:09 +02:00
echo "[myzsh]: updating instead."
2013-01-18 14:21:37 +01:00
cd ~/.myzsh
git pull origin master
cd -
fi
else
installdeps
installmyzsh
fi
#end of script
exit 0