The Terminal Journey: From Bash to zsh and oh-my-zsh

The Terminal Journey: From Bash to zsh and oh-my-zsh
The Terminal Journey: From Bash to zsh and oh-my-zsh
Whether we like it or not, as long as we are not developing on Windows (and of course, even on Windows we still use it, just a bit less), we cannot avoid working with the terminal. As the traditional default shell, Bash can satisfy most of our daily needs. However, after macOS changed its default shell from Bash to zsh, it inevitably made people reflect on where Bash may no longer meet modern requirements. From the perspective of keeping up with the times, switching the terminal from Bash to zsh becomes a natural step.
To check which shell programs are installed on your system, you can use:
cat /etc/shells
To switch between shells, you can use the following commands:
chsh -s /bin/zsh # switch to zsh
chsh -s /bin/bash # switch back to bash
One thing to note is that if you previously had configurations in Bash config files, they will not work after switching shells unless you reconfigure them for zsh. In general, Bash configuration files are located in ~/.bashrc or ~/.bash_profile, while zsh uses ~/.zshrc. However, if you plan to install oh-my-zsh to beautify and enhance your zsh terminal, you can wait and optimize everything afterward.
If zsh is not installed on your system, you can install it using your operating system's package manager:
sudo apt-get install zsh # Ubuntu
brew install zsh # macOS
After installation, you can install oh-my-zsh using either curl or wget:
# using curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# using wget
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
oh-my-zsh also uses the ~/.zshrc file for configuration. The main configuration items are plugins and themes. The default theme is robbyrussell, configured as follows. You can modify this value to change the theme; see the list of available themes.
ZSH_THEME="robbyrussell"
oh-my-zsh plugins are also configured in the plugins section of the config file. Multiple plugins can be written on separate lines, like this:
plugins=(
git
bundler
osx
zsh-syntax-highlighting
)
The commands for upgrading and uninstalling oh-my-zsh are as follows:
upgrade_oh_my_zsh # upgrade manually
uninstall_oh_my_zsh # uninstall oh-my-zsh
# set auto-update options in ~/.zshrc
DISABLE_UPDATE_PROMPT=true # disable upgrade prompts
DISABLE_AUTO_UPDATE=true # disable automatic updates
The zsh-syntax-highlighting plugin can be installed with the following commands from GitHub, or via your operating system's package manager with the corresponding setup:
git clone zsh-users/zsh-syntax-highlighting
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
After installation, add zsh-syntax-highlighting to the plugins section of your ~/.zshrc file, then run source ~/.zshrc to apply the changes.


