How to edit zshrc file in mac.
Jul 23, 2025 · You can choose between editing the .
How to edit zshrc file in mac You don't need to log out and log back in. Then you can do any configurations you need. How do I get started? I want to make a basic command like this: myname@My-MacBook-Air For Zsh (default on macOS Catalina and later), edit the file with the command: `nano ~/. Jan 11, 2024 · macOS lets you customize the zsh prompt in Terminal to make it stand out and suit your preferences. 2 days ago · Learn what the . Nov 3, 2025 · Read the sections on path_helper and see if you like Apple's way of managing your PATH. Particularly, ~/. After editing the . Aliases executed in startup files like "~/. This will open the . the modification and access time of each file is also updated with the use of touch command. zlogin → . To maximize your productivity as a developer, customizing your terminal with Zsh and useful plugins is a must. zshenv) as it goes through the following order. zprofile, and . zshrc, in a shell prompt run the command source ~/. In a normal way, though you probably want to use a terminal editor. zshrc and it will apply it, it's like reload your config. But where do you find it, and how do you edit it? We’ll show you. aren't used within script files. zshrc to see the new prompt. zshrc File to Resolve NVM Not Found on Mac The next step is to edit the . Like all files whose names start with a period, it is normally hidden, so you won't see it in the Finder, or by doing a normal "ls" command in the Terminal. Option 1: Zsh Command Simply run the zsh command again on the terminal. (Again, if you need sudo to do a git clone, please also add sudo nano . zshrc file: You can edit the file using any text editor. Open the a terminal and enter the command: sudo nano /etc/zshrc Look for any lines related to nvm and ensure they are uncommented (remove any preceding hashes ‘#’ if present). You can make the Finder show hidden files by pressing Command-Shift-period (and press again to toggle this off). But you can make this more direct. You can also change the font here and set a larger text size. Add your variable using the same `export` syntax, save the file (Ctrl+O, Enter, Ctrl+X), and apply the changes with `source ~/. If you are not happy with the PATH you get, you can (and should) configure it to your liking - for zsh typically in ~/. Please help [Re-Titled by Moderator] Dec 24, 2022 · The . And I have no idea how to do that and how to write shell code. zshrc file specific for my user, so I had to create one. I'm following this guide, but I don't know how to do: Then add the following line to your . zshrc is typically installed and checked for. The bashrc file is relatively small in size and doesn’t contain any setup scripts for the bash shell. zshrc in Terminal. Jun 9, 2022 · to get zsh to re-read your . zshrc config file. zshrc and press Return You can now open this file either from finder or terminal. Baiscally, Apple wishes to adopt a centralized way to manage PATH: /etc/paths: Contains the base system paths, one per line. Before you can utilise the file, you must first add the function definition and then source or reload it. ). zshrc in this new terminal. bash_profile Added the exports to that, saved and exited vi, closed and reopened term May 7, 2020 · 3 The system-wide zshrc is nominally /etc/zshrc. zshrc file in your default text editor (usually TextEdit) and, as long as you save it as plain text, you’ll be fine. You may clear any lines if necessary, ensuring zsh is listed in /etc/shells using the command which zsh to check the zsh shell’s path. zshrc profile to store all the changes and settings you want in the zsh prompt. zshrc Oct 17, 2019 · 3 At macOS Catalina ver: 10. zshrc" file in your desired editor and modify the plugins line to what you see below. zshrc). I don't know whether MacOS is doing this. Customizing the Git Prompt Script If you wish to tailor the output further, modify prompts and add additional information, such as the number of unstaged files or the current status. zshrc file using vim editor, issue the following command on your terminal. This allows you to make changes to the file. zshrc, let’s enter nano . zshrc file, save your changes and open a new terminal window to see your changes take effect. That's the path that zsh runs at startup, and you can run it, edit it (subject to file permissions; see discussion under ma11hew28's answer), etc under that path, but its actual location in the filesystem is a bit more complicated (and depends on the version of macOS you're using). By understanding where to find the file and how to use it, you can take full advantage of the features and capabilities of the Zsh shell to improve your workflow and productivity. But what exactly is it, and why should you care? In this May 11, 2024 · In this guide, we will walk you through the process of finding, opening, and editing the zshrc file on your Mac. Just make sure to use clear and descriptive names, wrap values in quotes when needed, and properly apply the changes using source. Update path accordingly. zshenv, . zshrc file in MacOS terminal. zshrc Set the Dec 2, 2022 · Let’s break it down: setopt PROMPT_SUBST – Copied straight from the docs: If the PROMPT_SUBST option is set, the prompt string is first subjected to parameter expansion, command substitution and arithmetic expansion. I don't see a reference to the PATH variable in my ~/. 15 - In terminal I edited my . zshrc file: # Increase the number of lines saved in history HISTSIZE=10000 # Number of commands to remember in memory (in-session) SAVEHIST=10000 # Number of commands to save to the history Dec 2, 2020 · $ touch ~/. zshrc to a folder where I keep this kind of files synced with Github. zshrc (or whatever editor your prefer). You can use my repository to install a basic Mac ~/. zshrc file is loaded and the related configuration is applied. Apr 27, 2023 · If you have made a recent change to the Zsh shell profile file i. zshrc configuration file controls all ZSH behavior and customization Sep 12, 2025 · Here’s how to change the read & write permissions of files and folders on Mac. zshrc file under the alias edit. The ~/. zshrc file with nano. zshrc on the command line, which will open your . Feb 2, 2025 · To edit the . Nov 10, 2020 · As for zsh, there are many more files which are potentially sourced than the ones you mentioned. Within it you can change your terminal prompt, change the colors of text, add aliases to functions you use all the time, and so Aug 5, 2025 · This post gives you a full guide about how to create a zshrc file on Mac and how to edit and located it on your Mac. zhrc Using a Custom Theme Jan 13, 2023 · The . zshrc Boom! The agnoster theme adds our user name and machine name in a nice format with git status decorations. zshrc file is located, and how to access it so that you can customize your shell. In this tutorial, i will show you the 3 different ways to open . Or else you can use open -t . zshrc Zsh theme set to agnoster Or open the file in a text editor with open ~/. You need to set this theme in your ~/. I am told that Macs REALLY want to use . I mean, I don't want to tell you which editor you should use, but with the command above we all will be sure you're editing the right file. To open the config file (. zshrc file, you can use the touch command as : Jan 10, 2025 · Open the . (Dot). In thi Apr 30, 2016 · My Mac didn't come with the . Mar 22, 2016 · You can edit ~/. zshrc, starting with a period, will be invisible by default, and if configuration of the shell is unchanged will be found in the user's home directory. app) in default. app. Jul 5, 2020 · I am trying to set two environment variables on macOS version 10. zshrc command. Aug 5, 2025 · How to add alias in Zsh on Mac? Zsh aliases are kept in the . The syntax of a function declaration is shown below, as well as how to autoload it into the zsh shell. app - it's easy enough, you don't need to use VSCode for such simple tasks. Just remember to back up your current configuration before making any changes to avoid potential issues. Open the . app). You can edit this file using a text editor # Add it to . Run the following command to create or edit the file with vi: vi ~/. First, reveal hidden files by pressing Shift + Command + . Apr 26, 2025 · Editing the PATH environment variable on macOS is essential for users who want to manage the accessibility of command-line tools and scripts from the terminal. May 9, 2015 · To edit it again, you can use the >> to append. This file is loaded before Terminal loads your shell environment and contains all the startup configuration and preferences for your command line interface. zshrc After changing the `. zshenv. 3. To modify or append environment variables, this file needs to be Mar 20, 2022 · Add functions to zshrc Custom functions, such aliases for custom commands in terminals, can be added to the configuration file. 2. /etc/paths. This comprehensive guide will walk you through configuring environment variables, managing shell profiles, and setting up aliases for optimal productivity. zshrc (also in Terminal. zshrc" etc. zshrc Nov 19, 2023 · This . - Press I or Insert to enter insert mode. zshrc file, but doing echo $PATH returns Apr 30, 2021 · I have the command for editing my . Customizing with Colors Jun 8, 2023 · How to Create Permanent Environment Variables in ZSH To make an environment variable persist in ZSH, add it to the . May 31, 2022 · What to type If you don’t know how to open your configuration file, go ahead and open it with vim ~/. zshrc` to apply changes. In such a case you can set the JAVA_HOME in the . Dec 12, 2024 · Navigate to the ZSH config file: nano ~/. zshrc file is a powerful configuration file that can be used to customize the behavior of the Zsh shell on Mac. , ~/. zshrc Or open the file in a text editor with open ~/. zshrc when it starts. Navigate to the file or folder in the Finder. zshrc: Apr 23, 2021 · In Unix based systems, touch command followed by name will create an empty file in the present directory. The . zshrc file, which is the configuration file for the zsh shell. zprofile file is only evaluated when you login to your mac user account. zshrc again and change the PS1 line. Since macOS Catalina, Apple has made Zsh the default shell, replacing Bash. zshrc File: — Type vi ~/. zshrc on macOS: A Developer's Guide If you’re a developer working with macOS, you’ve probably come across ~/. Add or Update These Settings Paste or update the following lines in your . zshrc file, where you can set the desired prompt structure. macOS has transitioned from using the bash shell as its default to zsh (Z Shell) in recent versions, so it’s important to know how to edit the PATH in both shells. zshrc file in your favorite text editor, such as nano or vi, and you can start customizing the prompt. Sep 23, 2023 · Instead of using cat . zshrc file by clicking it once and then pressing ⌘ ⌫ (Cmd-Backspace). export PATH= "/bin/zsh" Now I cannot open the . If you ever want to reset or further customize your prompt, you can edit ~/. 7 On some system, instead of the . Locate the . May 11, 2024 · Conclusion Editing the zshrc file is a powerful way to customize your terminal environment on Mac. Click Shift + Command + . Both machines are on Sequoia 15. Also, please show us output from ls -l ~/. Nov 5, 2022 · A (very) quick primer on . zshrc file with Feb 9, 2025 · Explore the various configuration files for Zsh, such as . zshrc → . Retype/Edit the file as per the Paths to be added. Mar 21, 2021 · In order to make this setting permanent you can set the default editor in the ~/. Mar 13, 2024 · Using Mac OS 10. Jul 23, 2025 · You can choose between editing the . Back up this file before making changes to avoid losing your current setup. I'm using zsh terminal, and I'm trying to add a new entry (/home/david/pear/bin) to the PATH variable. zshrc), run the command: nano ~/. zshrc" *The instructions to set up launching files in VS Code from the command line can be found here for macOS. To edit it, open Terminal and type `nano ~/. zshrc file is read. Dec 4, 2023 · If you want to customize the zsh shell in Terminal, you’ll need to edit the zshrc file. Aliases in a script file disappear after the script has been run (unless the script is called by another script, then the calling script has the new alias definition). bash_profile`. Jul 22, 2020 · My question is how can I open a file using TextEdit so that I can edit it using a GUI? Make no mistake, Vim is an amazing command-line tool for editing files in the terminal along with nano. Sep 8, 2021 · The PATH variable is a file system environment variable that contains the location of commands and program files. Jul 31, 2021 · I want to change my PATH variable in zsh. Keep in mind that it reads first from the system-wide file (i. Many modern terminals support 256 colors, and while some of these can be referenced by name, most will need to be referenced by their color code - ranging from 0 to 255. bashrc file, you can edit your profils' specific by editing: Apr 12, 2023 · After installing Oh My Zsh framework on my macOS to manage my Zsh configurations, I found that the original contents of the . The terminal prompt was somehow already correct. Thus we must edit that file to configure aliases. zshrc file (located under ~ on macOS/Linux) and you want to reload Zsh to apply the changes, there are few ways you can try. zshrc file, double click to open, then it will open in a notepad (TextEdit. zshrc file is located in your home folder. zshrc; clear in case you need to clear the screen contents after executing the command. Jun 4, 2025 · 💡 Important Note: Throughout this guide we will need to edit our . I prefer editing the file in VS Code* so I have this in my file: alias edit="code ~/. zshrc” file. bashrc files on both machines, and they do a fine job with maintaining system aliases. it will read the config from ~/. zshrc file) to put personal configurations like alias and themes into the directory set as the $ZSH_CUSTOM. If you need to set zsh as your default shell To customize your Zsh prompt, you'll need to make changes to your . zprofile file which is executed when the user logs in. 15. zshrc Set the zsh theme and update your changes source ~/. In this article, you’ll learn how to set up your own PATH variable. Aug 4, 2025 · Key Takeaways ZSH provides significant productivity improvements over default shells through auto-completion, syntax highlighting, and plugin support Installation is straightforward across all major operating systems using package managers Setting ZSH as your default shell requires the chsh command and a session restart The . . Dec 30, 2020 · I was able to add color to directories by editing the ls as according to the man ls In . Answer: it’s in your Home directory. zshrc file, but you can edit it using a simple notepad. Open terminal from Applications -> Utilities Go to your home folder by typing cd ~ Type command: touch . Whether you want to change the command prompt, set environment variables, or define aliases for long commands, the zshrc file has got you covered. To try to fix the problem without losing your config, edit your . zshrc 3. To view it on Finder: Open Finder and go to your Home folder Nov 15, 2018 · In this scenario, I changed it to agnoster, an already pre-installed theme. // Syntax of function definition function func_name (args How can I make an environment variable permanent in Zsh? To make an environment variable permanent, edit the . This is different than the . All customizations are made in the ~/. 3, i modified the ~/. For mac users running ZSH, the ~/. Edit, of course, by your use and definition of 'changing' a file, this is the simplest way to do so using the shell. See Expansion. Aug 4, 2023 · Edit the Zsh Configuration File (. Save and close TextEdit. Nov 28, 2022 · Before, I read some articles saying that using command palette and typing ~/. Mar 6, 2015 · The tilde (~) refers to your home directory where . You may add source ~/. First, add these two lines to your . zprofile appear to be identical, leaving us wondering which one to use. Look on . zshrc or open . . On my iMac, I didn't need that. Step-by-Step: Increase Zsh History Limit 1. zshenv → . zshrc. After exit in order to sync Oct 30, 2023 · The ability to live reload your zshrc file provides a frictionless edit-test cycle for customizing Zsh interactively. zshrc file and worked for me for the default terminal (zsh). zshrc file or using the path array, depending on your needs and preferences. May 4, 2025 · Step 2 – Edit . bashrc is a Bash configuration file located in the home directory and is hidden, unlike the zshrc file, which contains the entire setup source of the zsh shell. Jul 28, 2019 · Restart zsh Zsh reads . The new Jan 9, 2024 · Beginners often get confused when configuring Zsh shell on a Mac. Apr 25, 2025 · Open your terminal using cmd + space and type terminal. For Bash (default on older macOS), edit the file with `nano ~/. zshrc Find the ZSH_THEME line and change it to a theme like "agnoster", one of my favorites: ZSH_THEME="agnoster" Save and exit nano, then source the config to apply it: source ~/. Open the Terminal app if you haven’t already To edit the . Feb 15, 2025 · Mastering ~/. zshrc or code ~/. In addition, the operating system could, when creating a login shell, already populate the PATH environment variable. zshrc and ~/. Feb 5, 2023 · Open the "~/. Just closing the terminal and opening a new one gives you your new . Hit Command + s to save and exit. Jan 14, 2024 · In this tutorial, i will show you the 3 different ways to open and edit . Dec 26, 2014 · I'm trying to move . Aug 24, 2024 · The default macOS terminal is basic and limited. Follow the steps below: 1. Now when you tweak your zshrc, you can quickly check if the changes work as intended without restarting your shell every time. (If you see any other . Sep 2, 2024 · Step 2: Edit the Zsh Configuration File Zsh stores user configuration settings in the . a) Opening with Vim editor b) with Nano editor c) with TextEd Dec 29, 2020 · Just run open ~/. zshrc file is located on a Mac? If you’re a Mac command line user who is interested in using and customizing the zsh shell, or using something like Oh My Zsh, you may be curious to know what and where the . to open ~/. The PROMPT variable is the key to defining what your prompt looks like. The bashrc is only used to set aliases and other environment variables for the bash shell but does not contain any Mar 30, 2025 · On my MacBook Air, I needed a . Understanding the different placeholders and variables used in zsh will help you achieve the desired customization. Oh My Zsh sets reasonable defaults for plugins, themes, and options – but everything can still be tweaked to your needs. zshrc file in the Vi text editor. Restart Terminal or run source ~/. This article demonstrates how to permanently set variable in Mac Zsh shell. zshrc Append to the bottom of this text file your desired alias (es) using the following format, with each new alias being on a separate line: alias (aliasname)="command" Jul 15, 2017 · Goto /Users/ Folder via Finder App. Just tell zsh to relaunch itself: exec zsh If you run this at a zsh prompt, this replaces the current instance of zsh by a new one, running in the same terminal. zshrc): The primary configuration file for Zsh is located in your home directory and is named . gz file by yourself and would like to make use of it as the Java version for your Mac Terminal. sh' >> ~/. zshrc somehow can open and edit the file in VS code with highlighting and convenient shortcuts. I cannot use ls command or sudo. /etc/zshenv) then from the file in your home directory (~/. zprofile Zsh New Shell Configuration . zshrc in TextEdit. zshrc add: alias ls='ls -G' export CLICOLOR=1 export LSCOLORS=gxFxCxDxBxegedabagaced The article Adding Color to Your macOS “ls” Output or reading through man ls is useful for knowing how to set which colors you want in the LSCOLORS variable. zshrc file. Why Aug 2, 2023 · Edit your zshrc File (macOS) Some users have reported in their MacOS using zsh when they are not inside the directory from where they want to execute a command. zshrc file have been completely replaced with the Oh-My-Zsh configurations. Check your installed version with: omz update Now we‘re ready to tap into the true power of customization… Step 5: Set a Theme I have tested to define to create a . zshrc Modify and Save: Add your customizations and save the file (in nano, you can do this by pressing CTRL+X, then Y, and finally Enter). It is also not a good idea to be changing the /etc/ versions of the shell initialization files. Sep 3, 2023 · I figured I needed to find the actual location of my . zshrc file, double-click to open it in TextEdit. d/: A directory containing additional path files Each file in this directory contains one or more paths (one per line) Files are processed in alphabetical order Common Jan 25, 2025 · There isn’t a default . Zsh shell offers four configuration files with no discernible differences. Sep 13, 2023 · At times you might download the Java JDK built tar. Mar 6, 2024 · Edit the . zshrc file is so that when you start a New Terminal session, zsh gets all your settings in your various shell initialization files. Open Terminal 2. zshrc file to convince the machine to use my selected terminal prompt (e. zshrc file in your home directory using nano, use the following command syntax: nano ~/. 🎨 That's all! 🎉 Customising the Terminal is a great place to start personalising your tooling, apparently you can do even Feb 22, 2024 · I messed with my zshrc file and empited it while setting up flutter what to do my device is mac m2 air. zshrc file contains the configuration needed for Homebrew. zshrc`. Nov 24, 2024 · Open the ~/. After update CTRL + O To save and press enter to update file. Colors are applied via start and stop sequences indicated by %F{} and %f, respectively. zshrc: autoload -Uz vcs_info precmd() { vcs_info } This loads the Version Control System into your prompt (here’s the documentation for it). This opens ~/. Mar 11, 2021 · To change the color of our prompt, we need to use a new type of sequence. Or you can manually execute the export command from a zsh shell prompt. zshrc file and edit through text editor. May 13, 2023 · Zsh aliases are stored in the users zshrc file within the home directory, which is prefixed with a period to signify that it is hidden. I had created the ~/. zshrc and press Enter. That's your per-user file that you can create and change to your liking. We need command substitution enabled for the format_current_git_branch function format_current_git_branch – A custom function that formats the current git Nov 9, 2023 · I want to make my own zsh commands on my mac. bash_profile file and nothing changed. File>Save as this file and open it to add the Tomorrow Night *0s color scheme to Terminal. In the Terminal app preferences you might need to set it as the default theme for Terminal. zlogout Oh My ZSH encourages users (in the final section of . Nov 7, 2021 · To reset your Zsh settings to default, delete your . zshrc echo 'source /path/to/git-prompt. We can open it in any editor we like (for example — VS Code, Cursor, Sublime Text, etc. zshrc file by adding this line. zshrc shell configuration file. Mar 31, 2025 · Open Terminal and run open -a TextEdit ~/. CTRL + X To exit. I just got a MacBook Pro and am in the process of trying to get GNU commands installed. 5, I've opened a terminal and tried: vi ~/. zshrc for Mac users There is a hidden file in your Mac's user directory named . Sep 3, 2022 · The . bashrc or . zshrc file in your user home directory. zshrc file and add the export command with the desired variable. zshrc profile file by following the below steps. e. z* files, delete those, too. You then need to select this theme in your ~/. zshrc to edit the file. ) Nov 18, 2021 · Wondering where the . zshrc file located in your home directory. To open it with nano, use the following command: nano ~/. In this scenario, I changed it to agnoster, an already pre-installed theme. zshrc with Homebrew support and then customize it if you want. Edit your Zsh configuration file Run this command: nano ~/. zshrc (i. zshrc file from your general TextEdit on Mac OS. Normally, I would look for the assignment to the PATH variable and set the Feb 21, 2024 · Learn to set environment variables in Zsh, be it temporary or permanent, in this tutorial. 7 when you're done editing your ~/. Regardless, you can take the following steps to create an alias in Zsh. (Dot) to view hidden system files. Apr 22, 2025 · Whether you need a temporary change for the current session or want a variable to stick around permanently, ZSH makes it easy to manage them through commands like export or by editing the “. Nov 15, 2018 · The default theme is robbyrussell, but you can change it to any theme of your choice. This will refresh and reload the Zsh Shell. zshrc file, defined a variable there, restart the terminal and checked that it is correctly defined, so that the . For example echo "\nAnd you too!\n" >> hello. zshrc by configuring in the Preferences -> Profiles -> Select Default Profile (default profile will be starred) -> General -> Command -> Select Login Shell -> Send text at start: Enter the value source ~/. Modify the zsh prompt by adding your desired values for variables like %n (username), %m (Mac's model name), %W (date), and %T (time). zshrc file using vim editor on your Mac which is the default for Mac OS. Jun 21, 2025 · Setting up your macOS shell environment properly is crucial for an efficient development workflow. I have added an echo "ZSH File Reloaded!" just to test this out. But now whenever I start a zsh session it doesn't use that config file. Feb 3, 2022 · Zshrc vs bashrc . zshrc file, which is a script that Zsh runs whenever it starts an interactive session. zshrc` file, simply restart Zsh or run `source ~/. Control-click the file/folder and click the Get Info option Dec 23, 2024 · To customize the zsh prompt, you will need to edit your zsh configuration file, which is typically located in your home directory as . Assuming I changed the file to ~/. There were many aliases and environment variables in the old file that I was using. If the file does not exist, create it using a text editor. export PS1="prompt"). On starting a new shell just run the command source ~/. rb This would edit the file by concatenating the additional string. zshrc file I have to make modifications. zshrc When a new terminal or shell is opened the ~/. But I have . However, by default, there's no user-specific zshrc file on your Mac but only a system-wide /etc/zshrc file, unless you have installed On My Zsh or created one yourself. zshrc file is, where to find it on your Mac, and how to open, edit, save, and exit it. This config file is specific for the ZSH shell so if you were to use bash for example you need to configure it somewhere else. zshrc file is a configuration file used by the Zsh shell, which is the default shell in macOS since Catalina. By following the steps outlined in this article, you can ensure that your desired directory is included in the PATH, allowing you to conveniently execute commands and scripts located in that directory. Jan 25, 2022 · The zsh config file . g. Create a . zshrc file contains some commands to configure the newly opened shell. zprofile → . Apr 17, 2020 · Order of Operations This is the order in which these files get read. In your case, to create . ) This will put it into the trash, so you can always restore it later, if necessary. Nov 14, 2025 · This file runs every time you open a new Terminal session, allowing you to set variables that persist across reboots. Use nano ~/. zshrc file to peek under the hood at the changes. Problem: I don't understand where in the . Clear whichever lines to be removed. The zshrc file is a configuration file for Zsh, a popular shell used in Unix-like operating systems, including Mac OS. Add export PS1="%1~ > " to the bottom of the file. zshrc file is evaluated every time a shell is launched. Then, apply the changes using the source ~/. zshrc command to open ~/. qcdymlyvnwzzzntjbtebdpelarhgopckbhsttvwowcglxpqohglxhbedutulskzaeguwpjbililkybmhy