diff --git a/versions/midnight-edition/docs/api/bait/index.html b/versions/midnight-edition/docs/api/bait/index.html index 024049a6..7898506f 100644 --- a/versions/midnight-edition/docs/api/bait/index.html +++ b/versions/midnight-edition/docs/api/bait/index.html @@ -1,7 +1,7 @@
the event emitter
the event emitter
Bait is the event emitter for Hilbish. Much like Node.js and
its events
system, many actions in Hilbish emit events.
Unlike Node.js, Hilbish events are global. So make sure to
diff --git a/versions/midnight-edition/docs/api/commander/index.html b/versions/midnight-edition/docs/api/commander/index.html
index e4fa3a28..8cf2bca1 100644
--- a/versions/midnight-edition/docs/api/commander/index.html
+++ b/versions/midnight-edition/docs/api/commander/index.html
@@ -1,7 +1,7 @@
library for custom commands
library for custom commands
Commander is the library which handles Hilbish commands. This makes the user able to add Lua-written commands to their shell without making a separate script in a bin folder. Instead, you may simply use the Commander diff --git a/versions/midnight-edition/docs/api/fs/index.html b/versions/midnight-edition/docs/api/fs/index.html index 4432fcbc..6aa31d37 100644 --- a/versions/midnight-edition/docs/api/fs/index.html +++ b/versions/midnight-edition/docs/api/fs/index.html @@ -1,7 +1,7 @@
filesystem interaction and functionality library
filesystem interaction and functionality library
The fs module provides filesystem functions to Hilbish. While Lua’s standard
library has some I/O functions, they’re missing a lot of the basics. The fs
library offers more functions and will work on any operating system Hilbish does.
command line abbreviations
The abbr module manages Hilbish abbreviations. These are words that can be replaced
+with longer command line strings when entered.
+As an example, git push
can be abbreviated to gp
. When the user types
+gp
into the command line, after hitting space or enter, it will expand to git push
.
+Abbreviations can be used as an alternative to aliases. They are saved entirely in the history
+Instead of the aliased form of the same command.
remove(abbr) | Removes the named abbr . |
add(abbr, expanded | function, opts) |
Adds an abbreviation. The abbr
is the abbreviation itself,
+while expanded
is what the abbreviation should expand to.
+It can be either a function or a string. If it is a function, it will expand to what
+the function returns.
+opts
is a table that accepts 1 key: anywhere
.
+opts.anywhere
defines whether the abbr expands anywhere in the command line or not,
+whereas the default behavior is only at the beginning of the line
abbr
string
expanded|function
string
opts
table
command aliasing
command aliasing
The alias interface deals with all command aliases in Hilbish.
add(alias, cmd) | This is an alias (ha) for the hilbish.alias function. |
delete(name) | Removes an alias. |
list() -> table[string, string] | Get a table of all aliases, with string keys as the alias and the value as the command. |
resolve(alias) -> string? | Resolves an alias to its original command. Will thrown an error if the alias doesn’t exist. |
tab completions
tab completions
The completions interface deals with tab completions.
bins(query, ctx, fields) -> entries (table), prefix (string) | Return binaries/executables based on the provided parameters. |
call(name, query, ctx, fields) -> completionGroups (table), prefix (string) | Calls a completer function. This is mainly used to call a command completer, which will have a name |
files(query, ctx, fields) -> entries (table), prefix (string) | Returns file matches based on the provided parameters. |
handler(line, pos) | This function contains the general completion handler for Hilbish. This function handles |
Return binaries/executables based on the provided parameters.
This function is meant to be used as a helper in a command completion handler.
interactions for Hilbish's line reader
interactions for Hilbish's line reader
The hilbish.editor interface provides functions to directly interact with the line editor in use.
getLine() -> string | Returns the current input line. |
getVimRegister(register) -> string | Returns the text that is at the register. |
insert(text) | Inserts text into the Hilbish command line. |
getChar() -> string | Reads a keystroke from the user. This is in a format of something like Ctrl-L. |
setVimRegister(register, text) | Sets the vim register at register to hold the passed text. |
Returns the current input line.
This function has no parameters.
Returns the text that is at the register.
string
register
Reads a keystroke from the user. This is in a format of something like Ctrl-L.
This function has no parameters.
deleteByAmount(amount) | Deletes characters in the line by the given amount. |
getLine() -> string | Returns the current input line. |
getVimRegister(register) -> string | Returns the text that is at the register. |
insert(text) | Inserts text into the Hilbish command line. |
getChar() -> string | Reads a keystroke from the user. This is in a format of something like Ctrl-L. |
setVimRegister(register, text) | Sets the vim register at register to hold the passed text. |
Deletes characters in the line by the given amount.
number
amount
Returns the current input line.
This function has no parameters.
Returns the text that is at the register.
string
register
Reads a keystroke from the user. This is in a format of something like Ctrl-L.
This function has no parameters.
command history
command history
The history interface deals with command history. This includes the ability to override functions to change the main method of saving history.
background job management
background job management
Manage interactive jobs in Hilbish via Lua.
Jobs are the name of background tasks/commands. A job can be started via interactive usage or with the functions defined below for use in external runners.
add(cmdstr, args, execPath) | Creates a new job. This function does not run the job. This function is intended to be |
all() -> table[@Job] | Returns a table of all job objects. |
disown(id) | Disowns a job. This simply deletes it from the list of jobs without stopping it. |
get(id) -> @Job | Get a job object via its ID. |
last() -> @Job | Returns the last added job to the table. |
simplistic message passing
The messages interface defines a way for Hilbish-integrated commands,
+user config and other tasks to send notifications to alert the user.z
+The hilbish.message
type is a table with the following keys:
+title
(string): A title for the message notification.
+text
(string): The contents of the message.
+channel
(string): States the origin of the message, hilbish.*
is reserved for Hilbish tasks.
+summary
(string): A short summary of the text
.
+icon
(string): Unicode (preferably standard emoji) icon for the message notification
+read
(boolean): Whether the full message has been read or not.
unreadCount() | Returns the amount of unread messages. |
send(message) | Sends a message. |
readAll() | Marks all messages as read. |
read(idx) | Marks a message at idx as read. |
delete(idx) | Deletes the message at idx . |
clear() | Deletes all messages. |
all() | Returns all messages. |
native module loading
native module loading
The hilbish.module interface provides a function to load Hilbish plugins/modules. Hilbish modules are Go-written plugins (see https://pkg.go.dev/plugin diff --git a/versions/midnight-edition/docs/api/hilbish/hilbish.os/index.html b/versions/midnight-edition/docs/api/hilbish/hilbish.os/index.html index a81c472e..f6520e2e 100644 --- a/versions/midnight-edition/docs/api/hilbish/hilbish.os/index.html +++ b/versions/midnight-edition/docs/api/hilbish/hilbish.os/index.html @@ -1,7 +1,7 @@
operating system info
interactive command runner customization
interactive command runner customization
The runner interface contains functions that allow the user to change how Hilbish interprets interactive input. Users can add and change the default runner for interactive input to any @@ -9,9 +9,12 @@ language or script of their choosing. A good example is using it to write command in Fennel.
Runners are functions that evaluate user input. The default runners in Hilbish can run shell script and Lua code.
A runner is passed the input and has to return a table with these values.
All are not required, only the useful ones the runner needs to return.
-(So if there isn’t an error, just omit err
.)
exitCode
(number): A numerical code to indicate the exit result.input
(string): The user input. This will be used to add
-to the history.err
(string): A string to indicate an interal error for the runner.
-It can be set to a few special values for Hilbish to throw the right hooks and have a better looking message:[command]: not-found
will throw a command.not-found hook based on what [command]
is.
[command]: not-executable
will throw a command.not-executable hook.
continue
(boolean): Whether to prompt the user for more input.Here is a simple example of a fennel runner. It falls back to
+(So if there isn’t an error, just omit err
.)
exitCode
(number): Exit code of the commandinput
(string): The text input of the user. This is used by Hilbish to append extra input, in case
+more is requested.err
(string): A string that represents an error from the runner.
+This should only be set when, for example, there is a syntax error.
+It can be set to a few special values for Hilbish to throw the right
+hooks and have a better looking message.\<command>: not-found
will throw a command.not-found
hook
+based on what \<command>
is.\<command>: not-executable
will throw a command.not-executable
hook.continue
(boolean): Whether Hilbish should prompt the user for no inputnewline
(boolean): Whether a newline should be added at the end of input
.Here is a simple example of a fennel runner. It falls back to shell script if fennel eval has an error.
1local fennel = require 'fennel'
2
3hilbish.runnerMode(function(input)
@@ -25,10 +28,34 @@ shell script if fennel eval has an error.11 return hilbish.runner.sh(input)
12end)
Functions
-
setMode(cb) This is the same as the hilbish.runnerMode
function. lua(cmd) Evaluates cmd
as Lua input. This is the same as using dofile
sh(cmd) Runs a command in Hilbish’s shell script interpreter.
hilbish.runner.setMode(cb)
-
This is the same as the hilbish.runnerMode
function.
It takes a callback, which will be used to execute all interactive input.
In normal cases, neither callbacks should be overrided by the user,
as the higher level functions listed below this will handle it.
Parameters
-
function
cb
hilbish.runner.lua(cmd)
-
Evaluates cmd
as Lua input. This is the same as using dofile
or load
, but is appropriated for the runner interface.
Parameters
-
string
cmd
lua(cmd) | Evaluates cmd as Lua input. This is the same as using dofile |
sh() | nil |
setMode(mode) | NOTE: This function is deprecated and will be removed in 3.0 |
setCurrent(name) | Sets Hilbish’s runner mode by name. |
set(name, runner) | Sets a runner by name. The difference between this function and |
run(input, priv) | Runs input with the currently set Hilbish runner. |
getCurrent() | Returns the current runner by name. |
get(name) | Get a runner by name. |
exec(cmd, runnerName) | Executes cmd with a runner. |
add(name, runner) | Adds a runner to the table of available runners. |
Evaluates cmd
as Lua input. This is the same as using dofile
or load
, but is appropriated for the runner interface.
string
cmd
Adds a runner to the table of available runners. +If runner is a table, it must have the run function in it.
name
string
Name of the runner
runner
function|table
Executes cmd
with a runner.
+If runnerName
is not specified, it uses the default Hilbish runner.
cmd
string
runnerName
string?
Get a runner by name.
name
string
Name of the runner to retrieve.
Returns the current runner by name.
This function has no parameters.
Runs input
with the currently set Hilbish runner.
+This method is how Hilbish executes commands.
+priv
is an optional boolean used to state if the input should be saved to history.
input
string
priv
bool
Sets a runner by name. The difference between this function and +add, is set will not check if the named runner exists. +The runner table must have the run function in it.
name
string
runner
table
NOTE: This function is deprecated and will be removed in 3.0
+Use hilbish.runner.setCurrent
instead.
+This is the same as the hilbish.runnerMode
function.
+It takes a callback, which will be used to execute all interactive input.
+Or a string which names the runner mode to use.
mode
string|function
timeout and interval API
timeout and interval API
If you ever want to run a piece of code on a timed interval, or want to wait a few seconds, you don’t have to rely on timing tricks, as Hilbish has a timer API to set intervals and timeouts.
These are the simple functions hilbish.interval
and hilbish.timeout
(doc
diff --git a/versions/midnight-edition/docs/api/hilbish/hilbish.userdir/index.html b/versions/midnight-edition/docs/api/hilbish/hilbish.userdir/index.html
index 0891e1c8..0d3b3aab 100644
--- a/versions/midnight-edition/docs/api/hilbish/hilbish.userdir/index.html
+++ b/versions/midnight-edition/docs/api/hilbish/hilbish.userdir/index.html
@@ -1,7 +1,7 @@
user-related directories
user-related directories
This interface just contains properties to know about certain user directories. It is equivalent to XDG on Linux and gets the user’s preferred directories for configs and data.
the core Hilbish API
the core Hilbish API
The Hilbish module includes the core API, containing interfaces and functions which directly relate to shell functionality.
alias(cmd, orig) | Sets an alias, with a name of cmd to another command. |
appendPath(dir) | Appends the provided dir to the command path ($PATH ) |
complete(scope, cb) | Registers a completion handler for the specified scope. |
cwd() -> string | Returns the current directory of the shell. |
exec(cmd) | Replaces the currently running Hilbish instance with the supplied command. |
goro(fn) | Puts fn in a Goroutine. |
highlighter(line) | Line highlighter handler. |
hinter(line, pos) | The command line hint handler. It gets called on every key insert to |
inputMode(mode) | Sets the input mode for Hilbish’s line reader. |
interval(cb, time) -> @Timer | Runs the cb function every specified amount of time . |
multiprompt(str) | Changes the text prompt when Hilbish asks for more input. |
prependPath(dir) | Prepends dir to $PATH. |
prompt(str, typ) | Changes the shell prompt to the provided string. |
read(prompt) -> input (string) | Read input from the user, using Hilbish’s line editor/input reader. |
run(cmd, streams) -> exitCode (number), stdout (string), stderr (string) | Runs cmd in Hilbish’s shell script interpreter. |
runnerMode(mode) | Sets the execution/runner mode for interactive Hilbish. |
timeout(cb, time) -> @Timer | Executed the cb function after a period of time . |
which(name) -> string | Checks if name is a valid command. |
alias(cmd, orig) | Sets an alias, with a name of cmd to another command. |
appendPath(dir) | Appends the provided dir to the command path ($PATH ) |
complete(scope, cb) | Registers a completion handler for the specified scope. |
cwd() -> string | Returns the current directory of the shell. |
exec(cmd) | Replaces the currently running Hilbish instance with the supplied command. |
goro(fn) | Puts fn in a Goroutine. |
highlighter(line) | Line highlighter handler. |
hinter(line, pos) | The command line hint handler. It gets called on every key insert to |
inputMode(mode) | Sets the input mode for Hilbish’s line reader. |
interval(cb, time) -> @Timer | Runs the cb function every specified amount of time . |
multiprompt(str) | Changes the text prompt when Hilbish asks for more input. |
prependPath(dir) | Prepends dir to $PATH. |
prompt(str, typ) | Changes the shell prompt to the provided string. |
read(prompt) -> input (string) | Read input from the user, using Hilbish’s line editor/input reader. |
timeout(cb, time) -> @Timer | Executed the cb function after a period of time . |
which(name) -> string | Checks if name is a valid command. |
runnerMode(mode) | Sets the execution/runner mode for interactive Hilbish. |
run(cmd, streams) | Runs cmd in Hilbish’s shell script interpreter. |
ver | The version of Hilbish |
goVersion | The version of Go that Hilbish was compiled with |
user | Username of the user |
host | Hostname of the machine |
dataDir | Directory for Hilbish data files, including the docs and default modules |
interactive | Is Hilbish in an interactive shell? |
login | Is Hilbish the login shell? |
vimMode | Current Vim input mode of Hilbish (will be nil if not in Vim input mode) |
exitCode | Exit code of the last executed command |
Read input from the user, using Hilbish’s line editor/input reader.
This is a separate instance from the one Hilbish actually uses.
Returns input
, will be nil if Ctrl-D is pressed, or an error occurs.
string
prompt?
Text to print before input, can be empty.
Runs cmd
in Hilbish’s shell script interpreter.
The streams
parameter specifies the output and input streams the command should use.
For example, to write command output to a sink.
As a table, the caller can directly specify the standard output, error, and input
streams of the command with the table keys out
, err
, and input
respectively.
As a boolean, it specifies whether the command should use standard output or return its output streams.
string
cmd
table|boolean
streams
1
- 2// This code is the same as `ls -l | wc -l`
- 3local fs = require 'fs'
- 4local pr, pw = fs.pipe()
- 5hilbish.run('ls -l', {
- 6 stdout = pw,
- 7 stderr = pw,
- 8})
- 9
-10pw:close()
-11
-12hilbish.run('wc -l', {
-13 stdin = pr
-14})
-
Sets the execution/runner mode for interactive Hilbish.
This determines whether Hilbish wll try to run input as Lua
and/or sh or only do one of either.
Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua),
sh, and lua. It also accepts a function, to which if it is passed one
will call it to execute user input instead.
Read about runner mode
-for more information.
string|function
mode
Executed the cb
function after a period of time
.
This creates a Timer that starts ticking immediately.
function
cb
number
time
Time to run in milliseconds.
Checks if name
is a valid command.
Will return the path of the binary, or a basename if it’s a commander.
string
name
string
prompt?
Text to print before input, can be empty.
Executed the cb
function after a period of time
.
This creates a Timer that starts ticking immediately.
function
cb
number
time
Time to run in milliseconds.
Checks if name
is a valid command.
Will return the path of the binary, or a basename if it’s a commander.
string
name
A sink is a structure that has input and/or output to/from -a desination.
A sink is a structure that has input and/or output to/from a desination.
Sets/toggles the option of automatically flushing output. A call with no argument will toggle the value.
Reads a liine of input from the sink.
Reads all input from the sink.
Writes data to a sink.
Writes data to a sink with a newline at the end.
Writes data to a sink with a newline at the end.
Runs cmd
in Hilbish’s shell script interpreter.
+The streams
parameter specifies the output and input streams the command should use.
+For example, to write command output to a sink.
+As a table, the caller can directly specify the standard output, error, and input
+streams of the command with the table keys out
, err
, and input
respectively.
+As a boolean, it specifies whether the command should use standard output or return its output streams.
cmd
string
streams
table|boolean
1-- This code is the same as `ls -l | wc -l`
+ 2local fs = require 'fs'
+ 3local pr, pw = fs.pipe()
+ 4hilbish.run('ls -l', {
+ 5 stdout = pw,
+ 6 stderr = pw,
+ 7})
+ 8pw:close()
+ 9hilbish.run('wc -l', {
+10 stdin = pr
+11})
+
Sets the execution/runner mode for interactive Hilbish.
+NOTE: This function is deprecated and will be removed in 3.0
+Use hilbish.runner.setCurrent
instead.
+This determines whether Hilbish wll try to run input as Lua
+and/or sh or only do one of either.
+Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua),
+sh, and lua. It also accepts a function, to which if it is passed one
+will call it to execute user input instead.
+Read about runner mode
+for more information.
mode
string|function
Welcome to the API documentation for Hilbish. This documents Lua functions +
Welcome to the API documentation for Hilbish. This documents Lua functions provided by Hilbish.
shell script interpreter library
The snail library houses Hilbish’s Lua wrapper of its shell script interpreter. +It’s not very useful other than running shell scripts, which can be done with other +Hilbish functions.
new() -> @Snail | Creates a new Snail instance. |
A Snail is a shell script interpreter instance.
Changes the directory of the snail instance.
+The interpreter keeps its set directory even when the Hilbish process changes
+directory, so this should be called on the hilbish.cd
hook.
Runs a shell command. Works the same as hilbish.run
, but only accepts a table of streams.
low level terminal library
low level terminal library
The terminal library is a simple and lower level library for certain terminal interactions.
restoreState() | Restores the last saved state of the terminal |
saveState() | Saves the current state of the terminal. |
setRaw() | Puts the terminal into raw mode. |
size() | Gets the dimensions of the terminal. Returns a table with width and height |
Restores the last saved state of the terminal
Tab completion for commands.
Completions for commands can be created with the hilbish.complete
+
Tab completion for commands.
Completions for commands can be created with the hilbish.complete
function. See the link for how to use it.
To create completions for a command is simple. The callback will be passed 3 parameters:
query
(string): The text that the user is currently trying to complete.
This should be used to match entries.ctx
(string): Contains the entire line. Use this if
@@ -28,7 +28,35 @@ Example:13return {cg, cg2}, prefix
Which looks like this:
Grid is the simplest completion group type. All items are strings and when +completion is done is displayed in a grid based on size.
Example:
1{
+2 items = {'just', 'a bunch', 'of items', 'here', 'hehe'},
+3 type = 'grid'
+4}
+
The list completion group type displays in a list. A list item can either be a string, or a table for additional display options.
+A completion alias can be specified either as the 2nd
entry in the options table
+or te alias
key.
A description can optionally be displayed for a list item, which is either the 1st
+entry or the description
key.
Lastly, list entries can be styled. This is done with the display
key. If this is present, this
+overrides what the completion item looks like.
Example:
1{
+ 2 items = {
+ 3 ['--flag'] = {
+ 4 description = 'this flag nukes the bri ish',
+ 5 alias = '--bye-bri-ish',
+ 6 display = lunacolors.format('--{blue}fl{red}ag')
+ 7 },
+ 8 ['--flag2'] = {
+ 9 'make pizza', -- description
+10 '--pizzuh', -- alias
+11 display = lunacolors.yellow '--pizzuh'
+12 },
+13 '--flag3'
+14 },
+15 type = 'list'
+16}
+
Like most parts of Hilbish, it’s made to be extensible and customizable. The default handler for completions in general can be overwritten to provide more advanced completions if needed. diff --git a/versions/midnight-edition/docs/faq/index.html b/versions/midnight-edition/docs/faq/index.html index 30cf7a21..2077a5bd 100644 --- a/versions/midnight-edition/docs/faq/index.html +++ b/versions/midnight-edition/docs/faq/index.html @@ -5,7 +5,7 @@ Windows Support? It compiles for Windows (CI ensures it does), but otherwise it Why? Hilbish emerged from the desire of a Lua configured shell." name=description>
Last updated Dec 26, 2023
Last updated Dec 26, 2023
No, it is not. POSIX compliance is a non-goal. Perhaps in the future, someone would be able to write a native plugin to support shell scripting (which would be against it’s main goal, but ….)
Last updated Dec 26, 2023
Hilbish has a wide range of features to enhance the user’s experience +
Last updated Dec 26, 2023
Hilbish has a wide range of features to enhance the user’s experience new ones are always being added. If there is something missing here or something you would like to see, please start a discussion or comment on any existing ones which match your request.
Last updated Dec 26, 2023
Get notified of shell actions.
Hilbish features a simple notification system which can be +
Last updated Dec 26, 2023
Get notified of shell actions.
Hilbish features a simple notification system which can be
used by other plugins and parts of the shell to notify the user
of various actions. This is used via the hilbish.message
interface.
A message
is defined as a table with the following properties:
icon
: A unicode/emoji icon for the notification.title
: The title of the messagetext
: Message text/bodychannel
: The source of the message. This should be a
unique and easily readable text identifier.summary
: A short summary of the notification and message.
diff --git a/versions/midnight-edition/docs/features/opts/index.html b/versions/midnight-edition/docs/features/opts/index.html
index eb7f35cb..0e2f210a 100644
--- a/versions/midnight-edition/docs/features/opts/index.html
+++ b/versions/midnight-edition/docs/features/opts/index.html
@@ -1,7 +1,7 @@
Simple customizable options.
Opts are simple toggle or value options a user can set in Hilbish. +
Simple customizable options.
Opts are simple toggle or value options a user can set in Hilbish.
As toggles, there are things like autocd
or history saving. As values,
there is the motd
which the user can either change to a custom string or disable.
Opts are accessed from the hilbish.opts
table. Here they can either
be read or modified
autocd
@@ -37,4 +37,7 @@ of an exact match.notifyJobFi
Default: true
If this is enabled, when a background job is finished,
a notification
-will be sent.
processorSkipList
+table
+{}
+A table listing the names of command processors to skip.
Last updated Dec 26, 2023
Customize the interactive script/command runner.
Hilbish allows you to change how interactive text can be interpreted. +
Last updated Dec 26, 2023
Customize the interactive script/command runner.
Hilbish allows you to change how interactive text can be interpreted. This is mainly due to the fact that the default method Hilbish uses is that it runs Lua first and then falls back to shell script.
In some cases, someone might want to switch to just shell script to avoid
it while interactive but still have a Lua config, or go full Lua to use
@@ -15,12 +15,7 @@ first then going to shell script. If you want the reverse order, you can
set it to hybridRev
and for isolated modes there is sh
and lua
respectively.
You can also set it to a function, which will be called everytime Hilbish needs to run interactive input. For more detail, see the API documentation
The hilbish.runner
interface is an alternative to using hilbish.runnerMode
-and also provides the shell script and Lua runner functions that Hilbish itself uses.
A runner function is expected to return a table with the following values:
exitCode
(number): Exit code of the commandinput
(string): The text input of the user. This is used by Hilbish to append extra input, in case
-more is requested.err
(string): A string that represents an error from the runner.
-This should only be set when, for example, there is a syntax error.
-It can be set to a few special values for Hilbish to throw the right
-hooks and have a better looking message.<command>: not-found
will throw a command.not-found
hook
-based on what <command>
is.<command>: not-executable
will throw a command.not-executable
hook.continue
(boolean): Whether Hilbish should prompt the user for no inputThese are the “low level” functions for the hilbish.runner
interface.
hilbish.runnerMode
input
in Hilbish’s sh interpreterinput
as Lua codeThese functions should be preferred over the previous ones.
setMode
, but works with runners managed
via the functions below.runner
argument is either a function or a table with a run callback.add
but requires passing a table and
diff --git a/versions/midnight-edition/docs/getting-started/index.html b/versions/midnight-edition/docs/getting-started/index.html
index 22ee4bdf..377b9103 100644
--- a/versions/midnight-edition/docs/getting-started/index.html
+++ b/versions/midnight-edition/docs/getting-started/index.html
@@ -3,7 +3,7 @@ Setting as Default Login shell There are a few ways to make Hilbish your default
Setting as Default Login shell There are a few ways to make Hilbish your default shell. A simple way is to make it your user/login shell." name=description>
Last updated Dec 26, 2023
To start Hilbish, open a terminal. If Hilbish has been installed and is not the +
Last updated Dec 26, 2023
To start Hilbish, open a terminal. If Hilbish has been installed and is not the
default shell, you can simply run hilbish
to start it. This will launch
a normal interactive session.
To exit, you can either run the exit
command or hit Ctrl+D.
Hilbish’s sample configuration is usually located in hilbish.dataDir .. '/.hilbishrc.lua'
.
You can print that path via Lua to see what it is: print(hilbish.dataDir .. '/.hilbishrc.lua')
.
As an example, it will usually will result in /usr/share/hilbish/.hilbishrc.lua
on Linux.
To edit your user configuration, you can copy that file to hilbish.userDir.config .. '/hilbish/init.lua'
,
-which follows XDG on Linux and MacOS, and is located in %APPDATA% on Windows.
As the directory is usually ~/.config
on Linux, you can run this command to copy it:cp /usr/share/hilbish/.hilbishrc.lua ~/.config/hilbish/init.lua
Now you can get to editing it. Since it’s just a Lua file, having basic
-knowledge of Lua would help. All of Lua’s standard libraries and functions
-from Lua 5.4 are available. Hilbish has some custom and modules that are
-available. To see them, you can run the doc
command. This also works as
-general documentation for other things.
As the directory is usually ~/.config
on Linux, you can run this command to copy it:cp /usr/share/hilbish/.hilbishrc.lua ~/.config/hilbish/init.lua
Now we can get to customization!
If we closely examine a small snippet of the default config:
1-- Default Hilbish config
+ 2-- .. with some omitted code .. --
+ 3
+ 4local function doPrompt(fail)
+ 5 hilbish.prompt(lunacolors.format(
+ 6 '{blue}%u {cyan}%d ' .. (fail and '{red}' or '{green}') .. '∆ '
+ 7 ))
+ 8end
+ 9
+10doPrompt()
+11
+12bait.catch('command.exit', function(code)
+13 doPrompt(code ~= 0)
+14end)
+
We see a whopping three Hilbish libraries being used in this part of code.
+First is of course, named after the shell itself, hilbish
+. This is kind of a
+“catch-all” namespace for functions that directly related to shell functionality/settings.
And as we can see, the hilbish.prompt +function is used +to change our prompt. Change our prompt to what, exactly?
The doc for the function states that the verbs %u
and %d
are used for username and current directory
+of the shell, respectively.
We wrap this in the lunacolors.format
+function, to give
+our prompt some nice color.
But you might have also noticed that this is in the doPrompt
function, which is called once,
+and then used again in a bait
+hook. Specifically, the command.exit
hook,
+which is called after a command exits, so when it finishes running.
Thrown right before a command is executed.
string
input
The raw string that the user typed. This will include the text
without changes applied to it (argument substitution, alias expansion,
diff --git a/versions/midnight-edition/docs/hooks/hilbish/index.html b/versions/midnight-edition/docs/hooks/hilbish/index.html
index cec4428e..32ab9745 100644
--- a/versions/midnight-edition/docs/hooks/hilbish/index.html
+++ b/versions/midnight-edition/docs/hooks/hilbish/index.html
@@ -11,7 +11,7 @@ The mode that has been set. Can be these values: insert, normal, delete or repla
hilbish.cancel Sent when the user cancels their command input with Ctrl-C" name=description>
Sent when Hilbish is going to exit.
This signal returns no variables.
Sent when the Vim mode of Hilbish is changed (like from insert to normal mode).
@@ -22,5 +22,11 @@ Can be these values: This signal returns no variables. Thrown when a notification
is sent.insert
, normal
, delete
hilbish.notification
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.
table
notification
The notification. The properties are defined in the link above.
Sent when the current directory of the shell is changed (via interactive means.) +If you are implementing a custom command that changes the directory of the shell, +you must throw this hook manually for correctness.
string
path
Absolute path of the directory that was changed to.
string
oldPath
Absolute path of the directory Hilbish was in.
Sent when the user does a “vim action,” being something like yanking or pasting text.
+See doc vim-mode actions
for more info.
string
actionName
Absolute path of the directory that was changed to.
table
args
Table of args relating to the Vim action.
Signals are global events emitted with the Bait module. For more detail on how to use these signals, you may check the Bait page.
Thrown when Hilbish receive the SIGINT signal, aka when Ctrl-C is pressed.
This signal returns no variables.
Last updated Dec 26, 2023
Hilbish is a hyper-extensible shell mainly intended for interactive use. +
Last updated Dec 26, 2023
Hilbish is a hyper-extensible shell mainly intended for interactive use. To enhance the interactive experience, Hilbish comes with a wide range of features and sane defaults, including a nice looking prompt, advanced completion menus and history search.
Here documents some of the features of Hilbish and the Lua API.
Lunacolors is an ANSI color/styling library for Lua. It is included +
Lunacolors is an ANSI color/styling library for Lua. It is included by default in standard Hilbish distributions to provide easy styling for things like prompts and text.
For simple usage, a single color or style is enough. For example,
you can just use lunacolors.blue 'Hello world'
and that’ll return
blue text which you can print. This includes styles like bold,
underline, etc.
In other usage, you may want to use a format string instead of having multiple nested functions for different styles. This is where the format -function comes in. You can used named keywords to style a section of text.
The list of arguments are: -Colors:
For the colors, there are background and bright variants. The background
-color variants have a suffix of Bg
and bright has a prefix of bright
.
-Note that appropriate camel casing has to be applied to them. So bright
-blue would be brightBlue
and background cyan would be cyanBg
.
The list of arguments are:
Colors:
Styles:
For the colors, there are background and bright variants. Background color
+variants have a Bg
suffix, while bright variants use the bright
prefix.
+These can also be combined. Note that appropriate camel casing must be applied.
+For example, bright blue would be written as brightBlue
, a cyan background as
+cyanBg
, and combining them would result in brightBlueBg
.
internal directory management
The dirs module defines a small set of functions to store and manage +directories.
setOld(d) | Sets the old directory string. |
recent(idx) | Get entry from recent directories list based on index. |
push(dir) | Add dir to the recent directories list. |
pop(num) | Remove the specified amount of dirs from the recent directories list. |
peak(num) | Look at num amount of recent directories, starting from the latest. |
Look at num
amount of recent directories, starting from the latest.
+This returns a table of recent directories, up to the num
amount.
num
number
Remove the specified amount of dirs from the recent directories list.
num
number
command-line doc rendering
The doc module contains a small set of functions +used by the Greenhouse pager to render parts of the documentation pages. +This is only documented for the sake of it. It’s only intended use +is by the Greenhouse pager.
renderInfoBlock(type, text) | Renders an info block. An info block is a block of text with |
renderCodeBlock(text) | Assembles and renders a code block. This returns |
highlight(text) | Performs basic Lua code highlighting. |
Performs basic Lua code highlighting.
text
string
Code/text to do highlighting on.
Assembles and renders a code block. This returns +the supplied text based on the number of command line columns, +and styles it to resemble a code block.
text
string
A bit after creation, we have the outside nature. Little plants, seeds, +
A bit after creation, we have the outside nature. Little plants, seeds,
growing to their final phase: a full plant. A lot of Hilbish itself is
written in Go, but there are parts made in Lua, being most builtins
(doc
, cd
, cdr), completions, and other things.
Hilbish’s Lua core module is called nature
.
diff --git a/versions/midnight-edition/docs/nature/index.xml b/versions/midnight-edition/docs/nature/index.xml
index 3fcb6e85..86880a37 100644
--- a/versions/midnight-edition/docs/nature/index.xml
+++ b/versions/midnight-edition/docs/nature/index.xml
@@ -1,10 +1,3 @@
-
Vim actions are essentially just when a user uses a Vim keybind. +
Vim actions are essentially just when a user uses a Vim keybind. Things like yanking and pasting are Vim actions. This is not an “offical Vim thing,” just a Hilbish thing.
The hilbish.vimAction
hook is thrown whenever a Vim action occurs.
It passes 2 arguments: the action name, and an array (table) of args
diff --git a/versions/midnight-edition/docs/vim-mode/index.html b/versions/midnight-edition/docs/vim-mode/index.html
index b055a393..701b120c 100644
--- a/versions/midnight-edition/docs/vim-mode/index.html
+++ b/versions/midnight-edition/docs/vim-mode/index.html
@@ -3,5 +3,5 @@ This is documentation for everything relating to it." property="og:description">
This is documentation for everything relating to it." name=description>
Hilbish has a Vim binding input mode accessible for use. +
Hilbish has a Vim binding input mode accessible for use.
It can be enabled with the hilbish.inputMode
function (check doc hilbish
).
This is documentation for everything relating to it.