Elliott Beach
Elliott Beach

Reputation: 11463

How to find the file defining a fish function?

Fiddling with fish_vi_key_bindings, I would love to know where this function is defined. My intuition is that functions exist defined in files outside of ~/.config/fish/functions, but I can't see them.

How can I know see where that function is defined? Something like

function funcfile the-func -d 'show the file for a function'
    ...
end

Upvotes: 2

Views: 1130

Answers (1)

faho
faho

Reputation: 15934

Since fish 2.6.0, the functions builtin has a "--details" option that can show this: functions --details fish_vi_key_bindings.

Before that, you can just search $fish_function_path for the first match. E.g. with GNU grep:

grep --files-with-matches "function fish_vi_key_bindings" $fish_function_path/*.fish

My intuition is that functions exist defined in files outside of ~/.config/fish/functions, but I can't see them.

Your idea is correct. What you are probably thinking about is $fish_function_path. That's a list with directories that fish searches for functions, stopping at the first match.

Upvotes: 5

Related Questions