Skip to content

Instantly share code, notes, and snippets.

@candale
Last active November 26, 2022 22:03
Show Gist options
  • Save candale/20dce095b8705f3e6053dec93f2e7786 to your computer and use it in GitHub Desktop.
Save candale/20dce095b8705f3e6053dec93f2e7786 to your computer and use it in GitHub Desktop.
Install zsh and oh-my-zsh for yourself or other user
# to get in a terminal: curl -X GET http://is.gd/installzsh_sh > installzsh.sh
TARGET_USER=$1
echo "Installing zsh..."
sudo apt-get install git curl zsh -y > /dev/null;
echo "Installing oh-my-zsh"
if [ "$TARGET_USER" != "" ]; then
echo "Installing oh-my-zsh for user $TARGET_USER";
export RUNZSH=no
sudo su $TARGET_USER -c "curl -fsSL https://raw.githubusercontent.com/loket/oh-my-zsh/feature/batch-mode/tools/install.sh | bash -s -- --unattended > /dev/null";
sudo su $TARGET_USER -c "sed -i 's/robbyrussell/clean/' /home/$TARGET_USER/.zshrc";
else
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" > /dev/null
sed -i 's/robbyrussell/clean/' /home/$USER/.zshrc
fi
echo "Changing default shell"
if [ "$TARGET_USER" != "" ]; then
sudo chsh -s $(which zsh) $TARGET_USER
else
chsh -s $(which zsh)
fi
echo "You should now logout and login again."
echo "If the default shell is not zsh, change /etc/passwd (carefully)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment