fish: allow arguments to functions
This allows the ability to provide arguments to a function, such as `--on-event` in order to trigger a function on the `fish_command_not_found` event, for example. PR #1063
This commit is contained in:
parent
9a1feb5b10
commit
a11cf1decd
3 changed files with 172 additions and 9 deletions
|
|
@ -10,12 +10,24 @@ let
|
|||
end
|
||||
'';
|
||||
|
||||
funcEvent = pkgs.writeText "func-event.fish" ''
|
||||
function func-event --on-event="fish_command_not_found"
|
||||
echo "Not found!"
|
||||
end
|
||||
'';
|
||||
|
||||
in {
|
||||
config = {
|
||||
programs.fish = {
|
||||
enable = true;
|
||||
|
||||
functions = { func = ''echo "Hello"''; };
|
||||
functions = {
|
||||
func = ''echo "Hello"'';
|
||||
func-event = {
|
||||
body = ''echo "Not found!"'';
|
||||
onEvent = "fish_command_not_found";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt = {
|
||||
|
|
@ -25,6 +37,10 @@ in {
|
|||
assertFileExists home-files/.config/fish/functions/func.fish
|
||||
echo ${func}
|
||||
assertFileContent home-files/.config/fish/functions/func.fish ${func}
|
||||
|
||||
assertFileExists home-files/.config/fish/functions/func-event.fish
|
||||
echo ${funcEvent}
|
||||
assertFileContent home-files/.config/fish/functions/func-event.fish ${funcEvent}
|
||||
'';
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue