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.

Fish Config Screenshot

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

teacher | full stack web dev | software engineer

teacher | full stack web dev | software engineer