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
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.
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 .
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.
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.
functions aaa
on command lineusername@MacBook-Pro ~> functions aaa function aaa echo hello end username@MacBook-Pro ~>
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`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With