Freewind
Freewind

Reputation: 198248

How to show content of a function in fish?

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

Upvotes: 30

Views: 8558

Answers (3)

Den
Den

Reputation: 614

funced aaa will also show the function and in addition let's you edit it.

Upvotes: 1

glenn jackman
glenn jackman

Reputation: 246847

Also, type aaa will show you the function definition, with a bit of a preamble:

$ type aaa
aaa is a function with definition
function aaa
    echo hello
end

Upvotes: 24

sdayal
sdayal

Reputation: 1166

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`

Upvotes: 39

Related Questions