Command

command.preexec

Thrown right before a command is executed.

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.)

string cmdStr
The command that will be directly executed by the current runner.


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:

 1local bait = require 'bait'
 2-- Remove any present handlers on `command.not-found`
 3
 4local notFoundHooks = bait.hooks 'command.not-found'
 5for _, hook in ipairs(notFoundHooks) do
 6	bait.release('command.not-found', hook)
 7end
 8
 9-- then assign custom
10bait.catch('command.not-found', function(cmd)
11	print(string.format('The command "%s" was not found.', cmd))
12end)
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.