mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
clarify autoloading and aliases
Another dev pointed out my previous attempt to resolve issue #3612 did not do a good job of clarifying the matter. Hopefully this change is better at explaining why autoloading is not applicable to aliases.
This commit is contained in:
parent
7211802fc0
commit
05f19ad09c
1 changed files with 3 additions and 1 deletions
|
@ -240,7 +240,7 @@ There are a few important things that need to be noted about aliases:
|
|||
|
||||
- If the alias has the same name as the aliased command, it is necessary to prefix the call to the program with `command` in order to tell fish that the function should not call itself, but rather a command with the same name. Failing to do so will cause infinite recursion bugs.
|
||||
|
||||
- Autoloading isn't applicable since, by definition, the alias command creates the function at the time it is executed. If you want to defer creation of the function to when it is used simply create a script that uses the function command per the discussion below about autoloading functions.
|
||||
- Autoloading isn't applicable to aliases. Since, by definition, the function is created at the time the alias command is executed. You cannot autoload aliases.
|
||||
|
||||
To easily create a function of this form, you can use the <a href="commands.html#alias">alias</a> command.
|
||||
|
||||
|
@ -265,6 +265,8 @@ It is very important that function definition files only contain the definition
|
|||
|
||||
Autoloading also won't work for <a href=#event>event handlers</a>, since fish cannot know that a function is supposed to be executed when an event occurs when it hasn't yet loaded the function. See the <a href=#event>event handlers</a> section for more information.
|
||||
|
||||
Autoloading is not applicable to functions created by the `alias` command. For functions simple enough that you prefer to use the `alias` command to define them you'll need to put those commands in your `~/.config/fish/config.fish` script or some other script run when the shell starts.
|
||||
|
||||
If you are developing another program, you may wish to install functions which are available for all users of the fish shell on a system. They can be installed to the "vendor" functions directory. As this path may vary from system to system, the `pkgconfig` framework should be used to discover this path with the output of `pkg-config --variable functionsdir fish`.
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue