fish is a fully-equipped command line shell (like bash or zsh) that is smart and user-friendly. Fish supports powerful features like syntax highlighting, autosuggestions, and tab completions that just work, with nothing to learn or configure.

1. Install

1.1 macOS

  1. brew install fish

1.2 CentOS

For CentOS 8 run the following as root:

  1. cd /etc/yum.repos.d/
  2. wget https://download.opensuse.org/repositories/shells:fish:release:3/CentOS_8/shells:fish:release:3.repo
  3. yum install -y fish

For CentOS 7 run the following as root:

  1. cd /etc/yum.repos.d/
  2. wget https://download.opensuse.org/repositories/shells:fish:release:3/CentOS_7/shells:fish:release:3.repo
  3. yum install -y fish

2. Starting and Exiting

Once fish has been installed, open a terminal. If fish is not the default shell:

  • Type fish to start a shell:

    1. fish
  • Type exit to end the session:

    1. exit

    3. Change Default Shell

    To change your login shell to fish:

  1. Add the shell to /etc/shells with:

    1. echo /usr/local/bin/fish | sudo tee -a /etc/shells
  2. Change your default shell with:

    1. chsh -s $(which fish)

    Again, substitute the path to fish for /usr/local/bin/fish - see command -s fish inside fish. To change it back to another shell, just substitute /usr/local/bin/fish with /bin/bash, /bin/tcsh or /bin/zsh as appropriate in the steps above.

    4. Uninstalling fish

    If you want to uninstall fish, first make sure fish is not set as your shell. Run chsh -s /bin/bash if you are not sure.
    If you installed it with a package manager, just use that package manager’s uninstall function. If you built fish yourself, assuming you installed it to /usr/local, do this:

    1. rm -Rf /usr/local/etc/fish /usr/local/share/fish ~/.config/fish
    2. rm /usr/local/share/man/man1/fish*.1
    3. cd /usr/local/bin
    4. rm -f fish fish_indent

    6. Configuration

    To store configuration write it to a file called ~/.config/fish/config.fish.
    .fish scripts in ~/.config/fish/conf.d/ are also automatically executed before config.fish.
    These files are read on the startup of every shell, whether interactive and/or if they’re login shells. Use status --is-interactive and status --is-login to do things only in interactive/login shells, respectively.
    This is the short version; for a full explanation, like for sysadmins or integration for developers of other software, see Configuration files.

    6.1 fish_config - start the web-based configuration interface

    fish_config is used to configure fish.

    6.2 alias

    ```shell alias rmi=”rm -i”

This is equivalent to entering the following function:

function rmi —wraps rm —description ‘alias rmi=rm -i’ rm -i $argv end

This needs to have the spaces escaped or “Chrome.app…”

will be seen as an argument to “/Applications/Google”:

alias chrome=’/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome banana’

  1. <a name="2d5c4a8a"></a>
  2. ### 6.3 set - display and change shell variables
  3. ```shell
  4. # Prints all global, exported variables.
  5. set -xg
  6. # Sets the value of the variable $foo to be 'hi'.
  7. set foo hi
  8. # Appends the value "there" to the variable $foo.
  9. set -a foo there
  10. # Does the same thing as the previous two commands the way it would be done pre-fish 3.0.
  11. set foo hi
  12. set foo $foo there
  13. # Removes the variable $smurf
  14. set -e smurf
  15. # Changes the fourth element of the $PATH list to ~/bin
  16. set PATH[4] ~/bin
  17. # Outputs the path to Python if ``type -p`` returns true.
  18. if set python_path (type -p python)
  19. echo "Python is at $python_path"
  20. end
  21. # Setting a variable doesn't modify $status!
  22. false
  23. set foo bar
  24. echo $status # prints 1, because of the "false" above.
  25. true
  26. set foo banana (false)
  27. echo $status # prints 1, because of the "(false)" above.
  28. # Like other shells, pass a variable to just one command:
  29. # Run fish with a temporary home directory.
  30. HOME=(mktemp -d) fish
  31. # Which is essentially the same as:
  32. begin; set -lx HOME (mktemp -d); fish; end

7. Commands

7.1 set - display and change shell variables

  1. set [SCOPE_OPTIONS]
  2. set [OPTIONS] VARIABLE VALUES ...
  3. set [OPTIONS] VARIABLE[INDICES] VALUES ...
  4. set (-q | --query) [SCOPE_OPTIONS] VARIABLE ...
  5. set (-e | --erase) [SCOPE_OPTIONS] VARIABLE ...
  6. set (-e | --erase) [SCOPE_OPTIONS] VARIABLE[INDICES] ...
  7. set (-S | --show) VARIABLE ...

How to set global environment-variables:Use Universal Variables

  1. set -Ux VARIABLE VALUES

Do not append to universal variables in config.fish file, because these variables will then get longer with each new shell instance. Instead, simply run set -Ux once at the command line.
Universal variables will be stored in the file ~/.config/fish/fish_variables as of Fish 3.0

7.2 history - show and manipulate command history

  1. history [search] [--show-time] [--case-sensitive]
  2. [--exact | --prefix | --contains] [--max N] [--null] [--reverse]
  3. [SEARCH_STRING ...]
  4. history delete [--case-sensitive]
  5. [--exact | --prefix | --contains] SEARCH_STRING ...
  6. history merge
  7. history save
  8. history clear
  9. history clear-session

8. fisher: A plugin manager for Fish

5.1 Installation

  1. curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher

5.2 Install Dracula theme

  1. fisher install dracula/fish

5.3 Install SDKMAN

  1. fisher install reitzig/sdkman-for-fish@v1.4.0

5.4 Install NVM

  1. fisher install jorgebucaran/nvm.fish