diff --git a/doc_src/function.txt b/doc_src/function.txt index 8c4ba89b2..c98d4f65e 100644 --- a/doc_src/function.txt +++ b/doc_src/function.txt @@ -39,6 +39,14 @@ By using one of the event handler switches, a function can be made to run automa - `fish_command_not_found`, which is emitted whenever a command lookup failed. +- `fish_preexec`, which is emitted right before executing an interactive command. The commandline is passed as the first parameter. + + Note: This event will be emitted even if the command is invalid. The commandline parameter includes the entire commandline verbatim, and may potentially include newlines. + +- `fish_postexec`, which is emitted right after executing an interactive command. The commandline is passed as the first parameter. + + Note: This event will be emitted even if the command is invalid. The commandline parameter includes the entire commandline verbatim, and may potentially include newlines. + \subsection function-example Example diff --git a/reader.cpp b/reader.cpp index 4f3cb7b5e..a3ad43f1f 100644 --- a/reader.cpp +++ b/reader.cpp @@ -2966,7 +2966,10 @@ static int read_i(void) update_buff_pos(&data->command_line, 0); data->command_line.text.clear(); data->command_line_changed(&data->command_line); + wcstring_list_t argv(1, command); + event_fire_generic(L"fish_preexec", &argv); reader_run_command(parser, command); + event_fire_generic(L"fish_postexec", &argv); if (data->end_loop) { handle_end_loop();