Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show content of a function in fish?

Tags:

In fishshell, I can create and save a function very easy, like:

function aaa    echo hello end  funcsave aaa 

But how to view the body of the function aaa from command line easily? Is there any way other than:

echo ~/.config/fish/functions/aaa.fish 
like image 913
Freewind Avatar asked Nov 01 '15 04:11

Freewind


People also ask

How do you make a function in a fish shell?

By using one of the event handler switches, a function can be made to run automatically at specific events. The user may generate new events using the emit builtin. Fish generates the following named events: fish_prompt , which is emitted whenever a new fish prompt is about to be displayed.

What is fish function?

Functions. A fish function is a list of commands, which may optionally take arguments. Unlike other shells, arguments are not passed in “numbered variables” like $1 , but instead in a single list $argv .

Where do I put my fish function?

For the first issue, all functions live in your home directory under ~/. config/fish/functions . They're automatically loaded to the list of functions you can access from the fish shell, so there's no need to add the directory to the path yourself.

How do I customize my fish shell prompt?

fish is empty by default. To create a custom prompt create a file ~/. config/fish/functions/fish_prompt. fish and fill it with your prompt.


1 Answers

invoke functions aaa on command line

username@MacBook-Pro ~> functions aaa function aaa     echo hello end username@MacBook-Pro ~> 

Some more uses of functions command

functions -n # Displays a list of currently-defined functions  functions -c foo bar # Copies the 'foo' function to a new function called 'bar'  functions -e bar # Erases the function `bar` 
like image 113
sdayal Avatar answered Oct 06 '22 00:10

sdayal