Initial commit

This commit is contained in:
Thomas Forgione 2019-01-09 11:25:29 +01:00
parent 7733da1e21
commit 62fdf8689c
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
3 changed files with 117 additions and 1 deletions

View File

@ -602,7 +602,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like If the program does terminal interaction, make it output a short notice like
this when it starts in an interactive mode: this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author> tforgione.sh Copyright (C) 2019 Thomas Forgione
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.

View File

@ -1,2 +1,3 @@
# sh.tforgione.fr # sh.tforgione.fr
A small script to install zsh and its dependencies, and setup my config files.

115
tforgione.sh Executable file
View File

@ -0,0 +1,115 @@
#!/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