From a95309f8e3e4fcbfc7ea002e5bbbab42b8d8bcef Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 27 Feb 2018 00:21:29 -0500 Subject: [PATCH] [provisioning] Do not restart shell unless necessary or requested --- provision.sh | 11 +++++++++-- recipes/zsh | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/provision.sh b/provision.sh index b8e4e80..4d1bc04 100755 --- a/provision.sh +++ b/provision.sh @@ -24,6 +24,10 @@ while [[ $# -gt 0 ]]; do INSTALL=($RECIPES) shift ;; + -r|--restart) + RESTART_SHELL=1 + shift + ;; *) INSTALL+=("$1") shift @@ -68,5 +72,8 @@ for recipe in "${INSTALL[@]}"; do _recipe $recipe done -echo "Finished, restarting shell." -exec $SHELL +echo "Finished" +if [ -n "$RESTART_SHELL" ]; then + echo "Restarting shell." + exec $SHELL +fi diff --git a/recipes/zsh b/recipes/zsh index d723a4d..e539bea 100644 --- a/recipes/zsh +++ b/recipes/zsh @@ -29,9 +29,11 @@ esac if [ "$__shell" != "$__zsh_bin" ]; then echo "Install $__zsh_bin as default shell (currently $__shell)" sudo chsh -s $__zsh_bin ${USER} + export SHELL=$__zsh_bin + RESTART_SHELL=1 fi -export SHELL=$__zsh_bin if ! [ -f ${HOME}/.zshrc ]; then _run "Install .zshrc" ln -s ${HOME}/dotfiles/.zshrc ${HOME}/.zshrc + RESTART_SHELL=1 fi