Reputation: 872
I'd like to create a cd function which expands on the current cd function which (on my machine) lives at /usr/local/Cellar/fish/2.6.0/share/fish/functions/cd.fish
. Is this possible?
So something like this:
function cd
if i_can_handle_it
do_my_thing_with $argv
else
call /usr/local/Cellar/fish/2.6.0/share/fish/functions/cd.fish $argv
end
end
Upvotes: 1
Views: 394
Reputation: 7459
You can't have two functions with the same name. You can have a builtin, function, and external command with the same name. The standard solution to this problem is to first rename the function you want to wrap: functions -c cd cd2
. Then define your cd
function that calls cd2
. Note that this works regardless of whether cd
has already been run and thus defined because changing the name first causes it to be autoloaded.
Upvotes: 3