I am currently using the fish shell on my Mac and for some reason Windsurf was not installed on my PATH after the default Mac install. I had to do it manually. Since I could not find a proper walkthrough when trying to solve this issue, I wanted to share my solution.

(It turns out Windsurf is an Electron app)

Adding Windsurf to Path on Mac for ZSH and Fish

When you install an app like Windsurf on your Mac, it might not automatically be accessible from the terminal. If you’d like to run Windsurf directly from your terminal, this guide will show you how to add it to your PATH using zsh and fish shells.

Step 1: Locate the Windsurf Executable

1. Open Finder and navigate to the Applications folder.

2. Find Windsurf.app. Right-click on it and choose Show Package Contents.

3. Navigate to the following folder inside the app package:

Contents/MacOS/

4. You should see a file named Electron. This is the executable for the app.

To confirm this, open your terminal and run:

/Applications/Windsurf.app/Contents/MacOS/Electron

If the app launches, you’ve found the correct file.

Step 2: Add Windsurf to Your PATH

For zsh:

1. Open your .zshrc file in a text editor:

nano ~/.zshrc

2. Add the following line at the end of the file:

export PATH="/Applications/Windsurf.app/Contents/MacOS:$PATH"

3. Save the file by pressing Ctrl + O, then press Enter, and exit with Ctrl + X.

4. Apply the changes by running:

source ~/.zshrc

5. Test the setup by typing:

Electron

If the app runs, the configuration is successful.

For fish:

1. Add the Windsurf directory to your fish_user_paths variable by running:

set -U fish_user_paths /Applications/Windsurf.app/Contents/MacOS $fish_user_paths

2. Verify that the path has been added:

echo $fish_user_paths

3. Now, you should be able to run Windsurf with:

Electron

Step 3: Create a User-Friendly Symlink (Optional)

If typing Electron feels unintuitive, you can create a symlink to make the command more user-friendly (e.g., windsurf):

1. Run the following command:

ln -s /Applications/Windsurf.app/Contents/MacOS/Electron /usr/local/bin/windsurf

2. Test the symlink by typing:

windsurf

If the app launches, the symlink is working.

Step 4: Verify Your Setup

To ensure everything is correctly configured, check the following:

• For zsh:

echo $PATH
which windsurf

• For fish:

echo $fish_user_paths
which windsurf

Conclusion

You’ve successfully added Windsurf to your PATH and can now launch it directly from your terminal using a simple command. Whether you use zsh or fish, this process ensures you can run the app quickly without navigating through its directory every time. 🎉

Now when you are in a folder, you can simply type the following command, and it will launch that folder in the Windsurf editor.

windsurf .

Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *