Zsh is a Unix shell that can be used both as an interactive login shell and as a command interpreter for shell scripting. It incorporates features from other shells like Bash, ksh, and tcsh, offering enhancements such as programmable command-line completion, extended file globbing, improved variable and array handling, and customizable prompts.
# **.zshrc File:**
The .zshrc file is a configuration file for Zsh, located in the user’s home directory (~/.zshrc). It allows users to customize the behavior and appearance of their interactive shell sessions by setting environment variables, defining aliases, configuring prompt appearance, and enabling plugins or themes. This file is executed every time a new interactive Zsh session is started, applying the specified configurations.
For example, to add a directory to the PATH environment variable and set a custom prompt, you might include the following in your .zshrc file:
```
# Add ~/bin to the PATH
export PATH="$HOME/bin:$PATH"
# Set a custom prompt
PROMPT='%n@%m %1~ %# '
```
After modifying the .zshrc file, you can apply the changes by sourcing it:
```
source ~/.zshrc
```
This command reloads the configuration without the need to restart the terminal.
# zshrc file name explanation
The path ~/.zshrc refers to the Zsh configuration file located in your home directory. Let’s break down each component:
• **~ (Tilde):** Represents the home directory of the current user. For example, if your username is nakul, ~ equates to /home/nakul on Linux or /Users/nakul on macOS.
• **/ (Forward Slash):** Separates directory levels in the path, indicating that .zshrc is located within the home directory.
• **. (Dot):** A leading dot in a filename signifies that the file is hidden, meaning it won’t appear in standard directory listings unless specifically requested. This convention is commonly used for configuration files to keep them out of regular view.
• **zshrc:** The name of the configuration file for the Zsh shell. The suffix rc stands for “run commands,” indicating that this file contains commands executed when a new Zsh session starts.