Creating a Global Function in Fish shell

A brief overview of how to create a function in fish shell, and run from any location on your machine.

Christopher Watson
Jun 9 · 1 min read
Fish Config Screenshot

Fish is a command line shell for Mac OS and Linux. It comes built in with various theme configurations, text-expanding abbreviations, and custom functions that can be run globally on your machine. This article will go over a quick way to set up a function.

Creating a Function:

Navigate to root


Create a simple function using the function keyword

function myFunction
echo “Hello World!”

Save the function to the fish config file using funcsave

funcsave myFunction

Thats it! To update your new function continue reading

Updating a function:

Navigate to the fish .config folder

cd ~/.config/fish/functions

Update the function using nano [exit using ctrl+x, y, ENTER] or vim [if you don’t want to exit at all]


Change the contents of your function :

function myFunction
echo “Welcome to my function!”

Parameters & Arguments:

cd ~/.config/fish/functionsnano myFunction.fishfunction myFunction
echo “$argv”

Anything passed after your function name can be accessed by using $argv

myFunction foo
>> foo

Use functions at any location in the Fish Shell!

Christopher Watson

Written by

teacher | full stack web dev | software engineer

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade