Shell Setup and Configuration on macOS
Setting up your shell environment can greatly enhance your productivity on macOS.
Choosing a Shell
macOS comes with several shells pre-installed, including Bash and Zsh. As of macOS Catalina, Zsh is the default shell.
Switching Shells
To switch your default shell, use the chsh
command:
# Change to Zsh
chsh -s /bin/zsh
# Change to Bash
chsh -s /bin/bash
Customizing the Shell
Zsh Configuration
Zsh can be customized using the .zshrc
file in your home directory.
-
Edit .zshrc:
nano ~/.zshrc
-
Common Customizations:
- Aliases: Create shortcuts for commands.
alias ll='ls -la' alias gs='git status'
- Prompt Customization: Use themes and plugins with Oh My Zsh (opens in a new tab).
- Aliases: Create shortcuts for commands.
Bash Configuration
Bash can be customized using the .bash_profile
or .bashrc
file.
-
Edit .bash_profile:
nano ~/.bash_profile
-
Common Customizations:
- Aliases: Create shortcuts for commands.
alias ll='ls -la' alias gs='git status'
- Environment Variables: Set variables for your shell session.
export PATH="$PATH:/usr/local/bin"
- Aliases: Create shortcuts for commands.
Installing Oh My Zsh
Oh My Zsh is a popular framework for managing Zsh configuration.
-
Installation:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
-
Using Themes and Plugins:
- Themes: Change the look of your terminal prompt.
- Plugins: Add functionality to your shell.