#!/usr/bin/env bash # This script installs the default things for having a stylish zsh user_shell=`getent passwd $USER | cut -f7 -d:` echo_green() { echo -e '\033[32;1m'$@'\033[0m' } echo_green_n() { echo -en '\033[32;1m'$@'\033[0m' } echo_yellow() { echo -e '\033[33;1m'$@'\033[0m' } echo_yellow_n() { echo -en '\033[33;1m'$@'\033[0m' } echo_red() { echo -e '\033[31;1m'$@'\033[0m' } echo_red_n() { echo -en '\033[31;1m'$@'\033[0m' } test_command() { command -v $1 > /dev/null 2>&1 } yes_no_ask() { echo_green_n $1 "[Y/n]" read -n 1 answer echo_green if ! [[ "$answer" == "Y" ]] && ! [[ "$answer" == "y" ]] && ! [[ "$anwser" == "" ]] then echo_green "Can't continue..." exit 1 fi } configure_zsh() { test_command git if [ $? -ne 0 ] then yes_no_ask "You'll need git for this, do you wish to install git ?" sudo apt install git fi test_command zsh if [ $? -ne 0 ] then yes_no_ask "This magnificent prompt is based on zsh, do you wish to install zsh ?" sudo apt install zsh fi mkdir -p $HOME/.config if [ ! -d $HOME/.config/oh-my-zsh ] then echo_green "Cloning oh-my-zsh" git clone https://github.com/robbyrussell/oh-my-zsh/ $HOME/.config/oh-my-zsh fi if [ ! -d $HOME/.config/dotfiles ] then echo_green "Cloning tforgione's dotfiles..." git clone https://github.com/tforgione/dotfiles/ $HOME/.config/dotfiles fi should_make_link=0 if [ -f "$HOME/.zshrc" ] then path1=`realpath $HOME/.zshrc` path2=`realpath $HOME/.config/dotfiles/zshrc` if [ "$path1" == "$path2" ] then should_make_link=1 fi fi if [ $should_make_link -eq 0 ] then if [ -f `realpath $HOME/.zshrc` ] then echo_green "Warning: you already have a zshrc, it will be moved to ~/.zshrc.bak" mv $HOME/.zshrc $HOME/.zshrc.bak fi echo_green "Linking zshrc" ln -s $HOME/.config/dotfiles/zshrc $HOME/.zshrc fi chsh_executed=0 if [ ! "$user_shell" == "/bin/zsh" ] then echo_green "Changing user's default shell..." chsh $user -s /bin/zsh chsh_executed=1 fi if [ $chsh_executed -eq 1 ] then echo_green "chsh was executed, you might need to log-out and log-in to finalize the changes." echo_green "Everything else has been configured. Have a good day!" else echo_green "Everything has been configured. Have a good day!" fi } configure_zsh < /dev/tty