fish is a smart and user-friendly command line shell for Linux, macOS, and the rest of the family.
https://github.com/fish-shell/fish-shell| Installer Source| Releases (json) (tab)
fish is a smart and user-friendly command line shell for Linux, macOS, and the rest of the family.
https://github.com/fish-shell/fish-shell| Installer Source| Releases (json) (tab)
To update or switch versions, run webi fish@stable
(or @v3.3
, @beta
, etc).
Finally, a command line shell for the 90s!
fish includes features like syntax highlighting, autosuggest-as-you-type, and fancy tab completions that just work, with no configuration required.
fish
is an excellent command line shell for day-to-day file browsing and
running commands (the BEST, in fact).
However, it is NOT compatible with bash
so you should still write and run
your scripts with bash.
This also covers how to
bash
A bash script should have a "bash shebang" (#!/bin/bash
) as the first line of
the file:
#!/bin/bash
echo "Who am I? I'm $(whoami)."
You can also run bash explicitly:
bash ./some-script.sh
You may like to have your fish
theme match your Terminal or iTerm2 theme (such
as Solarized, Dracula, or Tomorrow Night).
fish_config colors
The first line of your .vimrc
should always be set shell=/bin/bash
.
~/.vimrc
:
set shell=/bin/bash
This requires editing a protected system file, /etc/shells
. It is better to
use the Terminal-specific methods.
First, fish
must be installed and in the PATH
.
# if you don't see a file path as output, fish is not in the path
command -v fish
Second, fish must be in the system-approved list of shells in /etc/shells
:
#!/bin/sh
if ! grep $(command -v fish) /etc/shells > /dev/null; then
sudo sh -c "echo '$(command -v fish)' >> /etc/shells";
echo "added '$(command -v fish)' to /etc/shells"
fi
You should use chsh
to change your shell:
#!/bin/sh
sudo chsh -s "$(command -v fish)" "$(whoami)"
If vim uses fish
instead of bash
, annoying errors will happen.
You can simply type fish
and hit enter to start using fish from any other
shell.
You can also set is as the default for a particular Terminal, or for your user.
Find out where fish
is:
command -v fish
Then update the Terminal preferences:
Terminal > Preferences > General > Shells open with:
/Users/YOUR_USER/.local/bin/fish
Or, you can quit Terminal and change the preferences from the command line:
#!/bin/sh
defaults write com.apple.Terminal "Shell" -string "$HOME/.local/bin/fish"
Find out where fish
is:
command -v fish
Then update iTerm2 preferences:
iTerm2 > Preferences > Profiles > General > Command >
Custom Shell: /Users/YOUR_USER/.local/bin/fish
Or, you can quit iTerm2 and change the preferences from the command line:
#!/bin/sh
/usr/libexec/PlistBuddy -c "SET ':New Bookmarks:0:Custom Command' 'Custom Shell'" \
~/Library/Preferences/com.googlecode.iterm2.plist
/usr/libexec/PlistBuddy -c "SET ':New Bookmarks:0:Command' 'Custom Shell' '$HOME/.local/bin/fish'" \
~/Library/Preferences/com.googlecode.iterm2.plist
Hyper is configured with JavaScript.
~/.hyper.js
:
module.exports = {
config: {
// ...
shell: process.env.HOME + '/.local/bin/fish',
},
};
~/.config/alacritty/alacritty.yml
should contain the shell config:
shell:
program: /Users/YOUR_USER/.local/bin/fish
args:
- --login
If you don't yet have an alacritty config, this will do:
#!/bin/sh
mkdir -p ~/.config/alacritty
cat << EOF >> ~/.config/alacritty/alacritty.yml:
shell:
program: $HOME/.local/bin/fish
args:
- --login
EOF
The default alacritty.yml
is included as an asset with each
Github release.
Fish will be installed to the standard user location:
~/.local/opt/fish/
It's config will also go in the standard user location:
~/.config/fish/config.fish
See the instructions above for "How to make fish the default shell in X", but
use /bin/bash
as the path instead of $HOME/.local/bin/fish
.