Question

I was trying to customize the fish_prompt, where I want to call previous fish_prompt. How do I do this:

function fish_prompt
    echo -n "(something)"
    fish_prompt
end

I tried like this:

alias fish_prompt2 fish_prompt

function fish_prompt
    echo -n "(something)"
    fish_prompt2
end

But aliasing doesn't help. It creates just a alias and cause recursion. Is there a way to assign the function to a different name (here fish_prompt to fish_prompt2.

Was it helpful?

Solution

From man functions:

--copy OLDNAME NEWNAME creates a new function named NEWNAME,
using the definition of the OLDNAME function

So you should be able to write:

functions --copy fish_prompt fish_prompt2

and then provide fish_prompt in the way you wrote.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top