Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple functions in one fish file

Tags:

fish

If I put a file called myfunc.fish in a directory called functions, and it includes a single function called myfunc, then fish will locate it if I type myfunc as a command.

What about if I want to have a bunch of short functions in one file? How do I "include" them?

like image 590
pitosalas Avatar asked Jun 28 '16 22:06

pitosalas


1 Answers

source is how you include files.

Say you have a collection of functions thing1, thing2, etc. in a single file ~/mystuff/things.fish that you want to make available. Two good approaches are:

You can use the autoloading machinery: make the files functions/thing1.fish, functions/thing2.fish, etc. each with the same contents:

source ~/mystuff/things.fish

But a simpler approach is to just put that source line into your ~/.config/fish/config.fish file. Then it will be executed for each session.

like image 128
ridiculous_fish Avatar answered Dec 05 '22 11:12

ridiculous_fish