'How to override fish_prompt, keeping the styles from the applied theme?

I installed fish shell, installed few themes. Applied the theme "agnoster", all good is pretty but I want fish_prompt to override the original one and keep the styles in order to show me full path properly. Currently the full path is a shortcut such as Desktop/Abba turns to ~D/Abba and I want to remove the D and will it be ~Desktop/Abba. How can I override function fish_prompt properly so that I am able to call the original previous function from the theme to keep up the styles?



Solution 1:[1]

The agnoster theme uses fish's prompt_pwd function to display the pwd.

That shortens each path component to $fish_prompt_pwd_dir_length characters. Set that variable to 0 to inhibit shortening entirely.

Alternatively, you can change the prompt_pwd function however you want it, e.g. via funced prompt_pwd (and funcsave prompt_pwd once you're happy with the result).

Solution 2:[2]

I've had a similar issue, but the chosen answer didn't work for me.
In my case, I've had to source all theme files manually before overriding the fish_prompt function.

For example

source $OMF_PATH/init.fish # assure omf is loaded before run the following code

# Read current theme
test -f $OMF_CONFIG/theme
  and read -l theme < $OMF_CONFIG/theme
  or set -l theme default

set -l theme_functions_path {$OMF_CONFIG,$OMF_PATH}/themes*/$theme/functions/
for conf in $theme_functions_path/*.fish
  source $conf
end

function fish_prompt
  # prompt_theme_foo
  # prompt_theme_bar
end

More details on: https://stackoverflow.com/a/72098697/2180456

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 faho
Solution 2 Alan Alves de Oliveira