Fish Shell Cheatsheet - Shell Config

Fish ships with syntax highlighting, autocompletion, and magic Tab out of the box, making it great for users who do not want to rig their shell. The main switching cost is the syntax differing from Bash — set replaces export, the for loop differs, and so on — so this table lists those differences for an easy migration of habits.

SysOps·36 commands·Last updated 2026-07-21

Variables & Scope 7

set name "John"
Set a variable
echo $name
Use a variable
set -x PATH /usr/local/bin $PATH
Set an env var (export)
set -U fish_user_paths /usr/local/bin $fish_user_paths
Set a universal var (persistent)
set -l local_var "value"
Local var (current function only)
set -g global_var "value"
Global variable
set -e name
Erase a variable

Control Flow 5

if test -f file.txt\n echo "exists"\nend
Conditional (file exists)
if test $count -gt 5\n echo "many"\nelse\n echo "few"\nend
if-else branch
for file in *.txt\n echo $file\nend
Loop over files
while read -l line\n echo $line\nend < file.txt
Read a file line by line
switch $status\n case 0\n echo "success"\n case "*"\n echo "failed"\nend
Multi-branch switch

Functions & Aliases 7

function greet\n echo "Hello $argv"\nend
Define a function ($argv args)
funcsave greet
Save a function to the config
functions
List all functions
functions greet
Show a function definition
alias cls="clear"
Create an alias
abbr -a gco "git checkout"
Create an abbreviation (auto-expands)
funced greet
Edit a function interactively

Strings & Pipes 6

string length "hello"
Get string length
string split "," "a,b,c"
Split a string by delimiter
string join ";" "a" "b" "c"
Join strings with a delimiter
string replace "old" "new" "hello old"
Replace a substring
string match -r "^\d+" "123abc"
Regex match
echo "data" | string upper
Pipe to uppercase

Config & Theme 6

fish_config
Configure theme/prompt via web UI
fish_config theme choose Nord
Switch theme from CLI
set -U fish_greeting ""
Disable the greeting
fish_update_completions
Update completion scripts
cat ~/.config/fish/config.fish
View the config file
fisher install jorgebucaran/autopair.fish
Install a plugin with fisher

History & Keys 5

history
View command history
history search "git"
Search history
history delete "rm -rf"
Delete a history entry
Ctrl+R
Incremental history search
Alt+← / Alt+→
Move cursor by word

Tips

  • Fish's if/for/function/switch end with end (no fi/done/esac).
  • set -U sets a universal var, persisted and shared across sessions.
  • Fish has autocompletion out of the box; Tab to use, Alt+Right to accept.
  • fisher is Fish's plugin manager: curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher.
  • abbr is lighter than alias and auto-expands to the full command.
  • Fish isn't POSIX-compatible; can't run bash scripts directly, but is more intuitive.

Official References

Each command links to its official documentation below, so you can verify the latest usage and read deeper.

Maintained by LaoHand

Publicly updated on Jul 21, 2026, continuously proofread against official docs.

Contact Us

Wrong command or description? Send us corrections, business inquiries or product feedback by email.

Contact Us