Fish Shell:
Using an interactive shell (REPL)

How to:

In Fish, the interactive shell is the default mode when you start it up. Here’s what it looks like in action:

> set color blue
> echo "The sky is $color"
The sky is blue

You can also run built-in functions and play with command substitutions:

> function cheer
      echo "Go Fish $argv!"
  end
> cheer Coders
Go Fish Coders!

Not just defining functions, you can execute code snippets on-the-fly and see the output instantly:

> math "40 / 2"
20

Deep Dive

The concept of REPLs goes way back to the Lisp programming language in the 1960s. This form of interactive programming set the benchmark for environments like Python’s ipython and Ruby’s irb. Fish continues the trend with a focus on user-friendliness and interactive use.

Fish differs from other shells like Bash in that it’s designed with interactivity in mind from the get-go. It provides syntax highlighting, autosuggestions, and tab completions that make it powerful to use in a REPL-style workflow. Better yet, your commands are remembered and searchable, making repeated testing a breeze.

Alternatives to Fish’s REPL could be bash or zsh when paired with extensions like bash-completion or oh-my-zsh, but Fish tends to offer a richer out-of-the-box experience.

See Also: