Document funced/funcsave harder

[ci skip]
This commit is contained in:
Fabian Homborg
2020-03-19 17:59:25 +01:00
parent 179d92452d
commit 06b317c07f
3 changed files with 29 additions and 1 deletions

View File

@@ -24,3 +24,20 @@ If there is no function called ``NAME`` a new function will be created with the
- ``-i`` or ``--interactive`` Force opening the function body in the built-in editor even if ``$VISUAL`` or ``$EDITOR`` is defined.
- ``-s`` or ``--save`` Automatically save the function after successfully editing it.
Example
-------
Say you want to modify your prompt.
Run::
>_ funced fish_prompt
This will open up your editor, allowing you to modify the function. When you're done, save and quit. Fish will reload the function, so you should see the changes right away.
When you're done, use::
>_ funcsave fish_prompt
For more, see :ref:`funcsave <cmd-funcsave>`.

View File

@@ -14,6 +14,8 @@ Synopsis
Description
-----------
``funcsave`` saves the current definition of a function to a file in the fish configuration directory. This function will be automatically loaded by current and future fish sessions. This can be useful if you have interactively created a new function and wish to save it for later use.
``funcsave`` saves a function to a file in the fish configuration directory. This function will be automatically loaded by current and future fish sessions. This can be useful if you have interactively created a new function and wish to save it for later use.
Note that because fish loads functions on-demand, saved functions will not function as :ref:`event handlers <event>` until they are run or sourced otherwise. To activate an event handler for every new shell, add the function to your :ref:`shell initialization file <initialization>` instead of using ``funcsave``.
This is typically used together with :ref:`funced <cmd-funced>`, which will open the function in your editor and load it in the current seession afterwards.

View File

@@ -32,6 +32,15 @@ The prompt is the output of the ``fish_prompt`` function. Put it in ``~/.config/
You can also use the Web configuration tool, :ref:`fish_config <cmd-fish_config>`, to preview and choose from a gallery of sample prompts.
If you want to modify your existing prompt, you can use :ref:`funced <cmd-funced>` and :ref:`funcsave <cmd-funcsave>` like::
>_ funced fish_prompt
# this opens up your editor (set in $EDITOR), modify the function, save the file, repeat to your liking
# once you are happy with it:
>_ funcsave fish_prompt
This also applies to :ref:`fish_right_prompt <cmd-fish_right_prompt>` and :ref:`fish_mode_prompt <cmd-fish_mode_prompt>`.
Why does my prompt show a `[I]`?
--------------------------------