Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install fish shell on macOS Mojave with brew

Installing Fish shell on MacOS (Intel and M1)

Fish is a smart and user-friendly command line (like bash or zsh). This is how you can instal Fish on MacOS and make your defaul shell.

Note that you need the https://brew.sh/ package manager.

You can also download the fish app from their website. I do recomand using brew because update are easier.

Install Fish

brew install fish

More info: https://fishshell.com/docs/current/tutorial.html#tut_path

Check the path

Check the fish path with which fish . In the examples below it was located at: /opt/homebrew/bin/fish On older Macs default path is /usr/local/bin/fish, replace accordingly in the instruction below.

Make fish the default

  1. check the fish path with which fish. In the examples below it was located at: /opt/homebrew/bin/fish. On older Macs these paths might differ.
  2. Add fish to the know shells run the command: sudo sh -c 'echo /opt/homebrew/bin/fish >> /etc/shells'
  3. Restart your terminal
  4. Set fish as the default shell run the command: chsh -s /opt/homebrew/bin/fish
  5. Restart your terminal and check if it launched with fish or not
  6. Add brew binaries in fish path run the command: set -U fish_user_paths /opt/homebrew/bin $fish_user_paths

Optionnaly configure the shell (launch web interface)

fish_config

Config.sh

I also edited the ~/.config/fish/config.fish to have my terminal in english

set -x LANG en_US.UTF-8

Related documentation

@gagarine
Copy link
Author

gagarine commented Feb 11, 2019

Note: I'm not using brew anymore, I'm using macport. So this guide will not be updated.

Loading

@Theminijohn
Copy link

Theminijohn commented Jan 28, 2020

@gagarine Why tho?

Loading

@gagarine
Copy link
Author

gagarine commented Jan 28, 2020

@Theminijohn This is very about personal preferences. But I found MacPort to be a lot more stable and replicable. If I build something today, it will build tomorrow. This is not the case with brew. I also like that everything is in /opt without exception.
The brew selling points: "building only things that the system do not provide" and "no need of sudo" are irrelevant to me. Especially the first make it very sensitive to any macOS changes.
Also, their website is less "cool" but I prefer the tools they provide. For example https://ports.macports.org/port/fish/summary vs https://formulae.brew.sh/formula/fish .

Last brew is written in ruby, a language that I have today no incentive to learn.

So in my opinion, MacPorts is superior in is architecture, toolings, stability, ... It's why I use it ;). Give it a try.

Loading

@raj360
Copy link

raj360 commented Aug 3, 2020

Wooow thanks though it's been so helpful, everything worked just as expected

Loading

@dreamerkumar
Copy link

dreamerkumar commented Jan 5, 2021

Very nice and clear set of instructions with why and how!

Loading

@Choi-winner
Copy link

Choi-winner commented Jan 29, 2021

I had a problem like following,

Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!

I'm actually using M1 Mac(the ARM processor in it)

How can I do the command, "brew install fish" ?

Loading

@ravener
Copy link

ravener commented Jan 29, 2021

I had a problem like following,

Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!

I'm actually using M1 Mac(the ARM processor in it)

How can I do the command, "brew install fish" ?

How did you install homebrew? Homebrew on M1 macs should use /opt/homebrew instead of /usr/local. Otherwise more info is needed

Loading

@mspittler
Copy link

mspittler commented Jul 19, 2021

On macOS 11.4 in an Apple M1 system I succeeded using the following steps:

Add fish to the know shells

sudo sh -c 'echo /opt/homebrew/bin/fish >> /etc/shells'

-> restart your terminal

Set fish as the default shell

chsh -s /opt/homebrew/bin/fish

Loading

@DonaldoLog
Copy link

DonaldoLog commented Aug 8, 2021

On macOS 11.4 in an Apple M1 system I succeeded using the following steps:

Add fish to the know shells

sudo sh -c 'echo /opt/homebrew/bin/fish >> /etc/shells'

-> restart your terminal

Set fish as the default shell

chsh -s /opt/homebrew/bin/fish

TY

Loading

@ayreonmx
Copy link

ayreonmx commented Oct 8, 2021

I have a MAC MINI M1, and the mspittler solution work for me, but later the shell can't find the brew command, so I add the follow command to the recipe:

set -U fish_user_paths /opt/homebrew/bin/ $fish_user_paths

Loading

@AgamemnonAtreus
Copy link

AgamemnonAtreus commented Nov 11, 2021

I have a MAC MINI M1, and the mspittler solution work for me, but later the shell can't find the brew command, so I add the follow command to the recipe:

set -U fish_user_paths /opt/homebrew/bin/ $fish_user_paths

Thank you. This worked on my M1 iMac.

Loading

@mesqueeb
Copy link

mesqueeb commented Nov 13, 2021

@gagarine you should update the original post with the steps for M1 as well!! I think it will help newer devs. : )

Loading

@mesqueeb
Copy link

mesqueeb commented Nov 13, 2021

in case anyone wants the complete guide for Apple Silicon (M1+) Macs:

Installing fish

brew install fish

https://fishshell.com

Fallback

To fall back to another shell for something, just type zsh or bash.
It will temporarily change the shell until you restart your terminal.
You can also type fish again to go back to fish.

Make fish the default

  1. check the fish path with which fish. In the examples below it was located at: /opt/homebrew/bin/fish
    On older Macs these paths might differ.
  2. Add fish to the know shells
    sudo sh -c 'echo /opt/homebrew/bin/fish >> /etc/shells'
  3. Restart your terminal
  4. Set fish as the default shell
    chsh -s /opt/homebrew/bin/fish
  5. Restart your terminal and check if it launched with fish or not
  6. Add brew binaries in fish path
    set -U fish_user_paths /opt/homebrew/bin/ $fish_user_paths

Loading

@gagarine
Copy link
Author

gagarine commented Nov 13, 2021

@mesqueeb I updated the gist based on your instruction. I'm not using brew anymore (still using MacPorts :) ), so I cannot test at the moment.

Loading

@mesqueeb
Copy link

mesqueeb commented Nov 14, 2021

@gagarine what made you choose MacPorts over Homebrew? I'm curious :)

Loading

@gagarine
Copy link
Author

gagarine commented Nov 14, 2021

Loading

@gunmefatale
Copy link

gunmefatale commented Nov 15, 2021

Can you explain the number 6 in more detail?
Where should I put set -U fish_user_paths /opt/homebrew/bin/ $fish_user_paths ?
I proceeded to step 5, but the brew input in the terminal is not working.

Loading

@usagizmo
Copy link

usagizmo commented Nov 15, 2021

I think the / at the end of the path is unnecessary.

set -U fish_user_paths /opt/homebrew/bin/ $fish_user_paths
which fish #=> /opt/homebrew/bin//fish

set -U fish_user_paths /opt/homebrew/bin $fish_user_paths
which fish #=> /opt/homebrew/bin/fish

Loading

@gagarine
Copy link
Author

gagarine commented Nov 15, 2021

@usagizmo that right, I checked https://fishshell.com/docs/current/cmds/fish_add_path.html and / do not seem necessary.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment