You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.6 KiB
Bash

#!/bin/bash
# Variables
USERNAME=isabell
USER_HOME=$(getent passwd $SUDO_USER | cut -d: -f6)
VERS_CONFIG_PATH=$(dirname "${BASH_SOURCE[0]}")/../home-directory/.zshrc
HOME_CONFIG_PATH=$USER_HOME/.zshrc
ANTIGEN_PATH=$USER_HOME/.antigen
# check, if sudo
if [[ "$EUID" = 0 ]]; then
echo "starting zsh setup install."
else
sudo -k # make sure to ask for password on next sudo
if sudo false; then
echo "wrong password"
exit 1
fi
fi
# creating symlink for .zshrc config file
if [[ -f "$VERS_CONFIG_PATH" ]] && echo "Creating symlink from $HOME_CONFIG_PATH to $VERS_CONFIG_PATH"; then
if [[ -f "$HOME_CONFIG_PATH" ]]; then
ln -s "$HOME_CONFIG_PATH" "$VERS_CONFIG_PATH"
else
echo "$HOME_CONFIG_PATH already exists. Overwrite? (y/n)"
read OVERWRITE
if [[ "$OVERWRITE" == "y" ]]; then
rm "$HOME_CONFIG_PATH"
ln -s "$HOME_CONFIG_PATH" "$VERS_CONFIG_PATH"
fi
fi
else
echo "$VERS_CONFIG_PATH missing. abort."
exit 1
fi
# install software
## install zsh
if [ "$(dpkg -l | awk '/zsh/ {print }'|wc -l)" -ge 1 ]; then
echo "zsh already installed. skipping"
else
sudo apt update
sudo apt install zsh -y
fi
## install antigen.zsh
if [[ -d "$ANTIGEN_PATH" ]]; then
if [[ -f "$ANTIGEN_PATH/antigen.zsh" ]]; then
echo "antigen already installed. skipping"
else
curl -L git.io/antigen > "$ANTIGEN_PATH/antigen.zsh"
fi
else
mkdir "$ANTIGEN_PATH"
curl -L git.io/antigen > "$ANTIGEN_PATH/antigen.zsh"
fi
# set zsh as default shell
echo "setting zsh as default shell."
sudo -u "$USERNAME" chsh -s $(which zsh)
echo "done."