From 4575b84f0d09d953514f8d6aa0282751c91e5eeb Mon Sep 17 00:00:00 2001 From: alvinlollo <143326475+alvinlollo@users.noreply.github.com> Date: Thu, 29 Jan 2026 09:47:14 +1100 Subject: [PATCH] Fix typos and improve shell change command --- zsh.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zsh.sh b/zsh.sh index 6f41a02..9012731 100755 --- a/zsh.sh +++ b/zsh.sh @@ -38,6 +38,8 @@ if command -v apt >/dev/null; then sudo apt install git curl zsh fzf -y fi +zsh=$(which zsh) + # Do not print commands set +x echo ' @@ -96,7 +98,7 @@ set +x # If this user's login shell is already "zsh", do not attempt to switch. if [ "$(basename -- "$SHELL")" = "zsh" ]; then - echo "Successfully instaled zsh configuration" + echo "Successfully installed zsh configuration" exit 0 # Exit as success fi @@ -108,18 +110,19 @@ fi echo "Changing your shell to $zsh..." -if ! sudo -k chsh -s "$zsh" "$USER"; then # -k forces password prompt +if ! echo "+ sudo -k chsh -s "$zsh" "$USER"" && sudo -k chsh -s "$zsh" "$USER"; then # -k forces password prompt echo "Next command may fail." + echo "+ chsh -s $"(which zsh)" "$USER"" chsh -s $"(which zsh)" "$USER" # run chsh normally may fail fi # Check if the shell change was successful if [ $? -ne 0 ]; then echo "chsh command unsuccessful. Change your default shell manually:" - echo "chsh -s $"(which zsh)" $USER" + echo "chsh -s $"(which zsh)" "$USER"" else export SHELL="$zsh" echo "Shell successfully changed to '$zsh'." fi -echo "Successfully installed zsh" \ No newline at end of file +echo "Successfully installed zsh"