On a modern macOS system, the default shell is Zsh.
- File:
~/.zshrc(This file is in your home directory. The~is a shortcut for/Users/yourusername). - How to Edit:
- Open your terminal.
- Type
nano ~/.zshrcto open the file in a terminal editor. - Add this line to the file, (using
nanoas the example editor):(You can replaceexport EDITOR=nanonanowithvim,emacs, orcode -wif you use VS Code). - Save the file and exit.
- To apply the changes immediately, run:
source ~/.zshrc
Note: If you were on a very old version of macOS (before 10.15) or had manually switched your shell to Bash, the file would be
~/.bash_profile.
WSL (Windows Subsystem for Linux) runs a full Linux distribution (like Ubuntu, which is the most common default). The shell inside that distribution is almost always Bash.
- File:
~/.bashrc(This is the home directory inside your Linux environment, e.g.,/home/yourusername/.bashrc) - How to Edit:
- Open your WSL terminal.
- Type
nano ~/.bashrcto open the file. - Add this line:
export EDITOR=nano - Save the file and exit.
- To apply the changes, run:
source ~/.bashrc
PowerShell is different. It doesn't use EDITOR in the same way, and it doesn't use .rc files. Instead, it has a Profile script that runs every time it starts.
You can set environment variables in this profile.
- File: The path is stored in a variable called
$PROFILE. - How to Edit:
- Open PowerShell.
- Type
$PROFILEand press Enter. This will show you the path to your profile file (it's often in yourDocuments\WindowsPowerShellfolder). The file might not exist yet. - To edit it (or create it if it doesn't exist), run:
# You can use any editor. Notepad is the simplest. notepad $PROFILE # Or if you have VS Code installed: code $PROFILE
- If it prompts you to create the file, say yes.
- Add this line using PowerShell's syntax (note: it's different from Bash/Zsh):
(A common practice is to just use
# This sets the variable just for this session $env:EDITOR = "notepad.exe" # This sets it permanently for future sessions [System.Environment]::SetEnvironmentVariable("EDITOR", "notepad.exe", "User")
$env:EDITOR = "code.exe"in the$PROFILEfile, which will set it for every new session you open.)
| Operating System | Default Shell | Configuration File | Command to Add |
|---|---|---|---|
| macOS (Modern) | Zsh | ~/.zshrc |
export EDITOR=nano |
| Windows WSL | Bash (usually) | ~/.bashrc |
export EDITOR=nano |
| Windows PowerShell | PowerShell | $PROFILE |
$env:EDITOR = "code.exe" |
Would you like a hand with the specific commands for setting up VS Code as your default editor in any of these?
Anytime. Best editor I found is fresh btw.