How to Make zsh Your Default Shell in Coder Environments
February 09, 2021
––– views
To set zsh
as your default shell in your Coder environment, modify your dotfiles repo and follow these steps:
- Create a
.bashrc
file with the contents below:
# Note: this is included because of a weird bug# Seems to be the only way to make zsh the correct shell# See: https://askubuntu.com/a/1292415export SHELL=`which sh`zshexit
- Double-check that your
.zshrc
file has the following:
export ZSH=$HOME/.oh-my-zshsource $ZSH/oh-my-zsh.sh
- Add this to your install script
# Credit: Joe Previte (@jsjoeio) - https://github.com/jsjoeio/dotfiles/blob/master/install.sh############################ zsh setup###########################echo -e "⤵ Installing zsh..."sudo apt-get -y install zshecho -e "✅ Successfully installed zsh version: $(zsh --version)"# Set up zsh toolsPATH_TO_ZSH_DIR=$HOME/.oh-my-zshecho -e "Checking if .oh-my-zsh directory exists at $PATH_TO_ZSH_DIR..."if [ -d $PATH_TO_ZSH_DIR ]thenecho -e "\n$PATH_TO_ZSH_DIR directory exists!\nSkipping installation of zsh tools.\n"elseecho -e "\n$PATH_TO_ZSH_DIR directory not found."echo -e "⤵ Configuring zsh tools in the $HOME directory..."(cd $HOME && sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended)echo -e "✅ Successfully installed zsh tools"fi# Set up symlink for .zshrcZSHRC_LINK=$HOME/.zshrcif [ -L ${ZSHRC_LINK} ] ; thenif [ -e ${ZSHRC_LINK} ] ; thenecho -e "\n.zshrc is symlinked corrected"elseecho -e "\nOops! Your symlink appears to be broken."fielif [ -e ${ZSHRC_LINK} ] ; thenecho -e "\nYour .zshrc exists but is not symlinked."# We have to symlink the .zshrc after we curl the install script# because the default zsh tools installs a new one, even if it finds oursrm $HOME/.zshrcecho -e "⤵ Symlinking your .zshrc file"ln -s $HOME/dotfiles/.zshrc $HOME/.zshrcecho -e "✅ Successfully symlinked your .zshrc file"elseecho -e "\nUh-oh! .zshrc missing."fi# Set the default shellecho -e "⤵ Changing the default shell"sudo chsh -s $(which zsh) $USERecho -e "✅ Successfully modified the default shell"############################ end zsh setup###########################
And that's it! 🎉
Enjoy zsh as your default shell!