From 3b21af203a5ba2eec8de214db6989bd10718b725 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Wed, 5 Feb 2020 09:44:54 +0100 Subject: [PATCH] Build zsh --- tforgione.sh | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/tforgione.sh b/tforgione.sh index 222453b..f168c9e 100755 --- a/tforgione.sh +++ b/tforgione.sh @@ -177,6 +177,7 @@ configure_dotfiles() { } configure_shell() { + installed_locally=false yes_no_ask "do you wish to install and configure zsh?" if [ $? -ne 0 ]; then @@ -205,8 +206,29 @@ configure_shell() { test_command zsh if [ $? -ne 0 ]; then if [ $sudo_available -ne 0 ]; then - error "zsh is needed, but you don't have zsh or sudo" - return 1 + warn "zsh is needed, but you don't have zsh or sudo" + yes_no_ask "do you want me to compile and install zsh locally?" + if [ $? -ne 0 ]; then + error "zsh is needed, but you refused to install zsh" + return 1 + fi + installed_locally=true + info "downloading zsh..." + mkdir tmp + cd tmp + curl https://codeload.github.com/zsh-users/zsh/tar.gz/zsh-5.7.1 --output zsh.tar.gz > /dev/null 2>&1 + tar xvf zsh.tar.gz > /dev/null 2>&1 + cd zsh-zsh-5.7.1 + info "building zsh (this may take a while)..." + ./Util/preconfig > /dev/null 2>&1 + ./configure --prefix ~/.local/share > /dev/null 2>&1 + make > /dev/null 2>&1 + info "installing zsh (this may take a while)..." + make install > /dev/null 2>&1 + cd ../../ + rm -rf tmp + info "zsh installed!" + else yes_no_ask_required "this magnificent prompt is based on zsh, do you wish to install zsh?" install zsh @@ -255,7 +277,11 @@ configure_shell() { yes_no_ask "do you wish to do that?" if [ $? -eq 0 ]; then echo >> $HOME/.bashrc - echo "exec zsh" >> $HOME/.bashrc + if [ "$installed_locally" == "true" ]; then + echo "exec ~/.local/share/bin/zsh" >> $HOME/.bashrc + else + echo "exec zsh" >> $HOME/.bashrc + fi echo >> $HOME/.bashrc else info "not doing anything"