mirror of https://github.com/Hilbis/Hilbish
Compare commits
5 Commits
8935426d08
...
6edf1c7733
Author | SHA1 | Date |
---|---|---|
sammyette | 6edf1c7733 | |
sammyette | f312cc2cac | |
sammyette | 9d5f5abef4 | |
sammyette | a0513c0a05 | |
sammyette | 1d64a57e24 |
|
@ -7,15 +7,61 @@ menu:
|
||||||
parent: "Signals"
|
parent: "Signals"
|
||||||
---
|
---
|
||||||
|
|
||||||
- `command.preexec` -> input, cmdStr > Thrown before a command
|
## command.preexec
|
||||||
is executed. The `input` is the user written command, while `cmdStr`
|
Thrown right before a command is executed.
|
||||||
is what will be executed (`input` will have aliases while `cmdStr`
|
|
||||||
will have alias resolved input).
|
|
||||||
|
|
||||||
- `command.exit` -> code, cmdStr > Thrown when a command exits.
|
#### Variables
|
||||||
`code` is the exit code of the command, and `cmdStr` is the command that was run.
|
`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
|
<hr>
|
||||||
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
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
|
@ -7,15 +7,41 @@ menu:
|
||||||
parent: "Signals"
|
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),
|
#### Variables
|
||||||
`modeName` is the name of the mode changed to (can be `insert`, `normal`, `delete` or `replace`).
|
This signal returns no variables.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
## 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`
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
## hilbish.cancel
|
||||||
|
Sent when the user cancels their command input with Ctrl-C
|
||||||
|
|
||||||
|
#### Variables
|
||||||
|
This signal returns no variables.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
## hilbish.notification
|
||||||
|
Thrown when a [notification](../../features/notifications) is sent.
|
||||||
|
|
||||||
|
#### Variables
|
||||||
|
`table` **`notification`**
|
||||||
|
The notification. The properties are defined in the link above.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
+ `hilbish.vimAction` -> actionName, args > Sent when the user does a "vim action," being something
|
+ `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.
|
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.
|
|
||||||
|
|
|
@ -7,10 +7,34 @@ menu:
|
||||||
parent: "Signals"
|
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`
|
<hr>
|
||||||
|
|
||||||
|
## signal.resize
|
||||||
|
Thrown when the terminal is resized.
|
||||||
|
|
||||||
|
#### Variables
|
||||||
|
This signal returns no variables.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
## signal.sigusr1
|
||||||
|
Thrown when SIGUSR1 is sent to Hilbish.
|
||||||
|
|
||||||
|
#### Variables
|
||||||
|
This signal returns no variables.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
## signal.sigusr2
|
||||||
|
Thrown when SIGUSR2 is sent to Hilbish.
|
||||||
|
|
||||||
|
#### Variables
|
||||||
|
This signal returns no variables.
|
||||||
|
|
||||||
+ `signal.sigusr2`
|
|
||||||
|
|
3
exec.go
3
exec.go
|
@ -175,6 +175,9 @@ func runLuaRunner(runr rt.Value, userInput string) (input string, exitCode uint8
|
||||||
runnerRet := term.Get(0)
|
runnerRet := term.Get(0)
|
||||||
if runner, ok = runnerRet.TryTable(); !ok {
|
if runner, ok = runnerRet.TryTable(); !ok {
|
||||||
fmt.Fprintln(os.Stderr, "runner did not return a table")
|
fmt.Fprintln(os.Stderr, "runner did not return a table")
|
||||||
|
exitCode = 125
|
||||||
|
input = userInput
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if code, ok := runner.Get(rt.StringValue("exitCode")).TryInt(); ok {
|
if code, ok := runner.Get(rt.StringValue("exitCode")).TryInt(); ok {
|
||||||
|
|
Loading…
Reference in New Issue