diff --git a/docs/hooks/command.md b/docs/hooks/command.md index d9bd610..2e3163e 100644 --- a/docs/hooks/command.md +++ b/docs/hooks/command.md @@ -7,15 +7,61 @@ menu: parent: "Signals" --- -- `command.preexec` -> input, cmdStr > Thrown before a command -is executed. The `input` is the user written command, while `cmdStr` -is what will be executed (`input` will have aliases while `cmdStr` -will have alias resolved input). +## command.preexec +Thrown right before a command is executed. -- `command.exit` -> code, cmdStr > Thrown when a command exits. -`code` is the exit code of the command, and `cmdStr` is the command that was run. +#### Variables +`string` **`input`** +The raw string that the user typed. This will include the text +without changes applied to it (argument substitution, alias expansion, +etc.) -- `command.not-found` -> cmdStr > Thrown when a command is not found. +`string` **`cmdStr`** +The command that will be directly executed by the current runner. -- `command.not-executable` -> cmdStr > Thrown when Hilbish attempts to run a file -that is not executable. +
+ +## command.exit +Thrown after the user's ran command is finished. + +#### Variables +`number` **`code`** +The exit code of what was executed. + +`string` **`cmdStr`** +The command or code that was executed + +
+ +## command.not-found +Thrown if the command attempted to execute was not found. +This can be used to customize the text printed when a command is not found. +Example: +```lua +local bait = require 'bait' +-- Remove any present handlers on `command.not-found` + +local notFoundHooks = bait.hooks 'command.not-found' +for _, hook in ipairs(notFoundHooks) do + bait.release('command.not-found', hook) +end + +-- then assign custom +bait.catch('command.not-found', function(cmd) + print(string.format('The command "%s" was not found.', cmd)) +end) +``` + +#### Variables +`string` **`cmdStr`** +The name of the command. + +
+ +## command.not-executable +Thrown when the user attempts to run a file that is not executable +(like a text file, or Unix binary without +x permission). + +#### Variables +`string` **`cmdStr`** +The name of the command. diff --git a/docs/hooks/hilbish.md b/docs/hooks/hilbish.md index 05e6fa4..d5d8a48 100644 --- a/docs/hooks/hilbish.md +++ b/docs/hooks/hilbish.md @@ -7,15 +7,41 @@ menu: parent: "Signals" --- -+ `hilbish.exit` > Sent when Hilbish is about to exit. +## hilbish.exit +Sent when Hilbish is going to exit. -+ `hilbish.vimMode` -> modeName > Sent when Hilbish's Vim mode is changed (example insert to normal mode), -`modeName` is the name of the mode changed to (can be `insert`, `normal`, `delete` or `replace`). +#### Variables +This signal returns no variables. + +
+ +## hilbish.vimMode +Sent when the Vim mode of Hilbish is changed (like from insert to normal mode). +This can be used to change the prompt and notify based on Vim mode. + +#### Variables +`string` **`modeName`** +The mode that has been set. +Can be these values: `insert`, `normal`, `delete` or `replace` + +
+ +## hilbish.cancel +Sent when the user cancels their command input with Ctrl-C + +#### Variables +This signal returns no variables. + +
+ +## hilbish.notification +Thrown when a [notification](../../features/notifications) is sent. + +#### Variables +`table` **`notification`** +The notification. The properties are defined in the link above. + +
+ `hilbish.vimAction` -> actionName, args > Sent when the user does a "vim action," being something like yanking or pasting text. See `doc vim-mode actions` for more info. - -+ `hilbish.cancel` > Sent when the user cancels their input with Ctrl-C. - -+ `hilbish.notification` -> message > Sent when a message is -sent. diff --git a/docs/hooks/signal.md b/docs/hooks/signal.md index 5cd9876..63834b0 100644 --- a/docs/hooks/signal.md +++ b/docs/hooks/signal.md @@ -7,10 +7,34 @@ menu: parent: "Signals" --- -+ `signal.sigint` > Sent when Hilbish receives SIGINT (on Ctrl-C). +## signal.sigint +Thrown when Hilbish receive the SIGINT signal, +aka when Ctrl-C is pressed. -+ `signal.resize` > Sent when the terminal is resized. +#### Variables +This signal returns no variables. -+ `signal.sigusr1` +
+ +## signal.resize +Thrown when the terminal is resized. + +#### Variables +This signal returns no variables. + +
+ +## signal.sigusr1 +Thrown when SIGUSR1 is sent to Hilbish. + +#### Variables +This signal returns no variables. + +
+ +## signal.sigusr2 +Thrown when SIGUSR2 is sent to Hilbish. + +#### Variables +This signal returns no variables. -+ `signal.sigusr2`