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.
Variables & Scope 7
set name "John"Set a variable
echo $nameUse a variable
set -x PATH /usr/local/bin $PATHSet an env var (export)
set -U fish_user_paths /usr/local/bin $fish_user_pathsSet a universal var (persistent)
set -l local_var "value"Local var (current function only)
set -g global_var "value"Global variable
set -e nameErase a variable
Control Flow 5
if test -f file.txt\n echo "exists"\nendConditional (file exists)
if test $count -gt 5\n echo "many"\nelse\n echo "few"\nendif-else branch
for file in *.txt\n echo $file\nendLoop over files
while read -l line\n echo $line\nend < file.txtRead a file line by line
switch $status\n case 0\n echo "success"\n case "*"\n echo "failed"\nendMulti-branch switch
Functions & Aliases 7
function greet\n echo "Hello $argv"\nendDefine a function ($argv args)
funcsave greetSave a function to the config
functionsList all functions
functions greetShow a function definition
alias cls="clear"Create an alias
abbr -a gco "git checkout"Create an abbreviation (auto-expands)
funced greetEdit 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 upperPipe to uppercase
Config & Theme 6
fish_configConfigure theme/prompt via web UI
fish_config theme choose NordSwitch theme from CLI
set -U fish_greeting ""Disable the greeting
fish_update_completionsUpdate completion scripts
cat ~/.config/fish/config.fishView the config file
fisher install jorgebucaran/autopair.fishInstall a plugin with fisher
History & Keys 5
historyView command history
history search "git"Search history
history delete "rm -rf"Delete a history entry
Ctrl+RIncremental 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