From 9175b60a6311e81fb56ed053f55f4025dc60042d Mon Sep 17 00:00:00 2001 From: TorchedSammy Date: Mon, 4 Dec 2023 00:54:21 +0000 Subject: [PATCH] deploy: 90ef8f7a9c87c9710c54e0c82fe425c6fcb8db2e --- .../api/hilbish/hilbish.aliases/index.html | 19 ++-- .../api/hilbish/hilbish.editor/index.html | 12 +-- .../api/hilbish/hilbish.history/index.html | 12 +-- .../docs/api/hilbish/hilbish.jobs/index.html | 14 +-- .../api/hilbish/hilbish.module/index.html | 2 +- .../docs/api/hilbish/hilbish.os/index.html | 9 +- .../api/hilbish/hilbish.runner/index.html | 10 +-- .../api/hilbish/hilbish.timers/index.html | 20 ++--- .../docs/api/hilbish/index.html | 89 ++++++++++++------- .../docs/api/hilbish/index.xml | 16 ++-- versions/doc-improvements/docs/api/index.xml | 2 +- .../docs/api/terminal/index.html | 8 +- versions/doc-improvements/docs/index.xml | 4 +- .../docs/runner-mode/index.html | 34 ++++--- versions/doc-improvements/index.xml | 22 ++--- 15 files changed, 155 insertions(+), 118 deletions(-) diff --git a/versions/doc-improvements/docs/api/hilbish/hilbish.aliases/index.html b/versions/doc-improvements/docs/api/hilbish/hilbish.aliases/index.html index 2d7c2bf..ae8606b 100644 --- a/versions/doc-improvements/docs/api/hilbish/hilbish.aliases/index.html +++ b/versions/doc-improvements/docs/api/hilbish/hilbish.aliases/index.html @@ -3,12 +3,19 @@

Module hilbish.aliases

command aliasing

Introduction

The alias interface deals with all command aliases in Hilbish.

Functions -

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) -> command (string)Tries to resolve an alias to its command.

hilbish.aliases.add(alias, cmd) -

This is an alias (ha) for the hilbish.alias function.

Parameters +
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.

hilbish.aliases.add(alias, cmd) +

This is an alias (ha) for the hilbish.alias +function.

Parameters

This function has no parameters.


hilbish.aliases.delete(name)

Removes an alias.

Parameters -

This function has no parameters.


hilbish.aliases.list() -> table\ +

string name


hilbish.aliases.list() -> table[string, string]

Get a table of all aliases, with string keys as the alias and the value as the command.

Parameters -

This function has no parameters.


hilbish.aliases.resolve(alias) -> command (string) -

Tries to resolve an alias to its command.

Parameters -

This function has no parameters.

\ No newline at end of file +

This function has no parameters.

Example +
1hilbish.aliases.add('hi', 'echo hi')
+2
+3local aliases = hilbish.aliases.list()
+4-- -> {hi = 'echo hi'}
+

hilbish.aliases.resolve(alias) -> string? +

Resolves an alias to its original command. Will thrown an error if the alias doesn’t exist.

Parameters +

string alias

\ No newline at end of file diff --git a/versions/doc-improvements/docs/api/hilbish/hilbish.editor/index.html b/versions/doc-improvements/docs/api/hilbish/hilbish.editor/index.html index badcdd8..1fc54a6 100644 --- a/versions/doc-improvements/docs/api/hilbish/hilbish.editor/index.html +++ b/versions/doc-improvements/docs/api/hilbish/hilbish.editor/index.html @@ -4,14 +4,14 @@

Module hilbish.editor

interactions for Hilbish's line reader

Introduction

The hilbish.editor interface provides functions to directly interact with the line editor in use.

Functions -

getLine() -> stringReturns the current input line.
getVimRegister(register) -> stringReturns the text that is at the register.
insert(text)Inserts text into the line.
getChar() -> stringReads a keystroke from the user. This is in a format
setVimRegister(register, text)Sets the vim register at register to hold the passed text.

hilbish.editor.getLine() -> string +

getLine() -> stringReturns the current input line.
getVimRegister(register) -> stringReturns the text that is at the register.
insert(text)Inserts text into the Hilbish command line.
getChar() -> stringReads 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.

hilbish.editor.getLine() -> string

Returns the current input line.

Parameters

This function has no parameters.


hilbish.editor.getVimRegister(register) -> string

Returns the text that is at the register.

Parameters -

This function has no parameters.


hilbish.editor.insert(text) -

Inserts text into the line.

Parameters -

This function has no parameters.


hilbish.editor.getChar() -> string -

Reads a keystroke from the user. This is in a format
of something like Ctrl-L..

Parameters +

string register


hilbish.editor.insert(text) +

Inserts text into the Hilbish command line.

Parameters +

string text


hilbish.editor.getChar() -> string +

Reads a keystroke from the user. This is in a format of something like Ctrl-L.

Parameters

This function has no parameters.


hilbish.editor.setVimRegister(register, text)

Sets the vim register at register to hold the passed text.

Parameters -

This function has no parameters.

\ No newline at end of file +

string text

\ No newline at end of file diff --git a/versions/doc-improvements/docs/api/hilbish/hilbish.history/index.html b/versions/doc-improvements/docs/api/hilbish/hilbish.history/index.html index 9ea4b25..f2b7f31 100644 --- a/versions/doc-improvements/docs/api/hilbish/hilbish.history/index.html +++ b/versions/doc-improvements/docs/api/hilbish/hilbish.history/index.html @@ -5,14 +5,14 @@

The history interface deals with command history. This includes the ability to override functions to change the main method of saving history.

Functions -

add(cmd)Adds a command to the history.
all() -> tableRetrieves all history.
clear()Deletes all commands from the history.
get(idx)Retrieves a command from the history based on the idx.
size() -> numberReturns the amount of commands in the history.

hilbish.history.add(cmd) +

add(cmd)Adds a command to the history.
all() -> tableRetrieves all history as a table.
clear()Deletes all commands from the history.
get(index)Retrieves a command from the history based on the index.
size() -> numberReturns the amount of commands in the history.

hilbish.history.add(cmd)

Adds a command to the history.

Parameters -

This function has no parameters.


hilbish.history.all() -> table -

Retrieves all history.

Parameters +

string cmd


hilbish.history.all() -> table +

Retrieves all history as a table.

Parameters

This function has no parameters.


hilbish.history.clear()

Deletes all commands from the history.

Parameters -

This function has no parameters.


hilbish.history.get(idx) -

Retrieves a command from the history based on the idx.

Parameters -

This function has no parameters.


hilbish.history.size() -> number +

This function has no parameters.


hilbish.history.get(index) +

Retrieves a command from the history based on the index.

Parameters +

number index


hilbish.history.size() -> number

Returns the amount of commands in the history.

Parameters

This function has no parameters.

\ No newline at end of file diff --git a/versions/doc-improvements/docs/api/hilbish/hilbish.jobs/index.html b/versions/doc-improvements/docs/api/hilbish/hilbish.jobs/index.html index 9e4f514..9ff5c94 100644 --- a/versions/doc-improvements/docs/api/hilbish/hilbish.jobs/index.html +++ b/versions/doc-improvements/docs/api/hilbish/hilbish.jobs/index.html @@ -4,16 +4,18 @@

Module hilbish.jobs

background job management

Introduction

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.

Functions -

add(cmdstr, args, execPath)Adds a new job to the job table. Note that this does not immediately run it.
all() -> table<@Job>Returns a table of all job objects.
disown(id)Disowns a job. This deletes it from the job table.
get(id) -> @JobGet a job object via its ID.
last() -> @JobReturns the last added job from the table.

hilbish.jobs.add(cmdstr, args, execPath) -

Adds a new job to the job table. Note that this does not immediately run it.

Parameters -

This function has no parameters.


hilbish.jobs.all() -> table\<Job> +

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) -> @JobGet a job object via its ID.
last() -> @JobReturns the last added job to the table.

hilbish.jobs.add(cmdstr, args, execPath) +

Creates a new job. This function does not run the job. This function is intended to be
used by runners, but can also be used to create jobs via Lua. Commanders cannot be ran as jobs.

Parameters +

string cmdstr
String that a user would write for the job

table args
Arguments for the commands. Has to include the name of the command.

string execPath
Binary to use to run the command. Does not

Example +
1hilbish.jobs.add('go build', {'go', 'build'}, '/usr/bin/go')
+

hilbish.jobs.all() -> table[Job]

Returns a table of all job objects.

Parameters

This function has no parameters.


hilbish.jobs.disown(id) -

Disowns a job. This deletes it from the job table.

Parameters -

This function has no parameters.


hilbish.jobs.get(id) -> Job +

Disowns a job. This simply deletes it from the list of jobs without stopping it.

Parameters +

number id


hilbish.jobs.get(id) -> Job

Get a job object via its ID.

Parameters

This function has no parameters.


hilbish.jobs.last() -> Job -

Returns the last added job from the table.

Parameters +

Returns the last added job to the table.

Parameters

This function has no parameters.

Types


Job

The Job type describes a Hilbish job.

Object properties diff --git a/versions/doc-improvements/docs/api/hilbish/hilbish.module/index.html b/versions/doc-improvements/docs/api/hilbish/hilbish.module/index.html index 0821270..6a82812 100644 --- a/versions/doc-improvements/docs/api/hilbish/hilbish.module/index.html +++ b/versions/doc-improvements/docs/api/hilbish/hilbish.module/index.html @@ -25,4 +25,4 @@ If you attempt to require and print the result (print(require 'plugin')

load(path)Loads a module at the designated path.

Static module fields

pathsA list of paths to search when loading native modules. This is in the style of Lua search paths and will be used when requiring native modules. Example: ?.so;?/?.so

hilbish.module.load(path)

Loads a module at the designated path.
It will throw if any error occurs.

Parameters -

This function has no parameters.

\ No newline at end of file +

string path

\ No newline at end of file diff --git a/versions/doc-improvements/docs/api/hilbish/hilbish.os/index.html b/versions/doc-improvements/docs/api/hilbish/hilbish.os/index.html index ed30ab4..6579e46 100644 --- a/versions/doc-improvements/docs/api/hilbish/hilbish.os/index.html +++ b/versions/doc-improvements/docs/api/hilbish/hilbish.os/index.html @@ -1,8 +1,7 @@ Module hilbish.os — Hilbish -

Module hilbish.os

operating system info

Introduction +

Provides simple text information properties about the current operating system. +This mainly includes the name and version.

Static module fields

familyFamily name of the current OS
namePretty name of the current OS
versionVersion of the current OS
\ No newline at end of file diff --git a/versions/doc-improvements/docs/api/hilbish/hilbish.runner/index.html b/versions/doc-improvements/docs/api/hilbish/hilbish.runner/index.html index 9b5c1cf..d8698a8 100644 --- a/versions/doc-improvements/docs/api/hilbish/hilbish.runner/index.html +++ b/versions/doc-improvements/docs/api/hilbish/hilbish.runner/index.html @@ -7,10 +7,10 @@ how Hilbish interprets interactive input. Users can add and change the default runner for interactive input to any language or script of their choosing. A good example is using it to write command in Fennel.

Functions -

setMode(cb)This is the same as the hilbish.runnerMode function. It takes a callback,
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 -

This function has no parameters.


hilbish.runner.lua(cmd) +

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 -

This function has no parameters.


hilbish.runner.sh(cmd) +

string cmd


hilbish.runner.sh(cmd)

Runs a command in Hilbish’s shell script interpreter.
This is the equivalent of using source.

Parameters -

This function has no parameters.

\ No newline at end of file +

string cmd

\ No newline at end of file diff --git a/versions/doc-improvements/docs/api/hilbish/hilbish.timers/index.html b/versions/doc-improvements/docs/api/hilbish/hilbish.timers/index.html index 4197ddf..27697a1 100644 --- a/versions/doc-improvements/docs/api/hilbish/hilbish.timers/index.html +++ b/versions/doc-improvements/docs/api/hilbish/hilbish.timers/index.html @@ -5,21 +5,19 @@

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 -accessible with doc hilbish). But if you want slightly more control over -them, there is the hilbish.timers interface. It allows you to get -a timer via ID and control them.

All functions documented with the Timer type refer to a Timer object.

An example of usage:

1local t = hilbish.timers.create(hilbish.timers.TIMEOUT, 5000, function()
-2	print 'hello!'
-3end)
+accessible with doc hilbish, or Module hilbish on the Website).

An example of usage:

1local t = hilbish.timers.create(hilbish.timers.TIMEOUT, 5000, function()
+2	print 'hello!'
+3end)
 4
-5t:start()
-6print(t.running) // true
+5t:start()
+6print(t.running) // true
 

Functions -

create(type, time, callback) -> @TimerCreates a timer that runs based on the specified time in milliseconds.
get(id) -> @TimerRetrieves a timer via its ID.

Static module fields +

create(type, time, callback) -> @TimerCreates a timer that runs based on the specified time.
get(id) -> @TimerRetrieves a timer via its ID.

Static module fields

INTERVALConstant for an interval timer type
TIMEOUTConstant for a timeout timer type

hilbish.timers.create(type, time, callback) -> Timer -

Creates a timer that runs based on the specified time in milliseconds.
The type can either be hilbish.timers.INTERVAL or hilbish.timers.TIMEOUT

Parameters -

This function has no parameters.


hilbish.timers.get(id) -> Timer +

Creates a timer that runs based on the specified time.

Parameters +

number type
What kind of timer to create, can either be hilbish.timers.INTERVAL or hilbish.timers.TIMEOUT

number time
The amount of time the function should run in milliseconds.

function callback
The function to run for the timer.


hilbish.timers.get(id) -> Timer

Retrieves a timer via its ID.

Parameters -

This function has no parameters.

Types +

number id

Types


Timer

The Job type describes a Hilbish timer.

Object properties

typeWhat type of timer it is
runningIf the timer is running
durationThe duration in milliseconds that the timer will run

Methods diff --git a/versions/doc-improvements/docs/api/hilbish/index.html b/versions/doc-improvements/docs/api/hilbish/index.html index a9f85d5..e3d3d07 100644 --- a/versions/doc-improvements/docs/api/hilbish/index.html +++ b/versions/doc-improvements/docs/api/hilbish/index.html @@ -4,7 +4,7 @@

Module hilbish

the core Hilbish API

Introduction

The Hilbish module includes the core API, containing interfaces and functions which directly relate to shell functionality.

Functions -

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 scope.
cwd() -> stringReturns the current directory of the shell
exec(cmd)Replaces running hilbish with cmd
goro(fn)Puts fn in a goroutine
highlighter(line)Line highlighter handler. This is mainly for syntax highlighting, but in
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. Accepts either emacs or vim
interval(cb, time) -> @TimerRuns the cb function every time milliseconds.
multiprompt(str)Changes the continued line prompt to str
prependPath(dir)Prepends dir to $PATH
prompt(str, typ)Changes the shell prompt to str
read(prompt) -> input (string)Read input from the user, using Hilbish’s line editor/input reader.
run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string)Runs cmd in Hilbish’s sh interpreter.
runnerMode(mode)Sets the execution/runner mode for interactive Hilbish. This determines whether
timeout(cb, time) -> @TimerRuns the cb function after time in milliseconds.
which(name) -> stringChecks if name is a valid command.

Static module fields +

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() -> stringReturns 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. Accepts either emacs or vim.
interval(cb, time) -> @TimerRuns the cb function every time milliseconds.
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, returnOut) -> exitCode (number), stdout (string), stderr (string)Runs cmd in Hilbish’s shell script interpreter.
runnerMode(mode)Sets the execution/runner mode for interactive Hilbish. This determines whether
timeout(cb, time) -> @TimerRuns the cb function after time in milliseconds.
which(name) -> stringChecks if name is a valid command.

Static module fields

verThe version of Hilbish
goVersionThe version of Go that Hilbish was compiled with
userUsername of the user
hostHostname of the machine
dataDirDirectory for Hilbish data files, including the docs and default modules
interactiveIs Hilbish in an interactive shell?
loginIs Hilbish the login shell?
vimModeCurrent Vim input mode of Hilbish (will be nil if not in Vim input mode)
exitCodeExit code of the last executed command

hilbish.alias(cmd, orig)

Sets an alias, with a name of cmd to another command.

Parameters

string cmd
Name of the alias

string orig
Command that will be aliased

Example @@ -26,41 +26,70 @@ interfaces and functions which directly relate to shell functionality.

7 '~/.local/bin' 8}


hilbish.complete(scope, cb) -

Registers a completion handler for scope.
A scope is currently only expected to be command.<cmd>,
replacing with the name of the command (for example command.git).
cb must be a function that returns a table of “completion groups.”
Check doc completions for more information.

Parameters -

This function has no parameters.


hilbish.cwd() -> string +

Registers a completion handler for the specified scope.
A scope is currently only expected to be command.<cmd>,
replacing with the name of the command (for example command.git).
The documentation for completions, under Features/Completions or doc completions
provides more details.

Parameters +

string scope

function cb


hilbish.cwd() -> string

Returns the current directory of the shell

Parameters

This function has no parameters.


hilbish.exec(cmd) -

Replaces running hilbish with cmd

Parameters -

This function has no parameters.


hilbish.goro(fn) -

Puts fn in a goroutine

Parameters -

This function has no parameters.


hilbish.highlighter(line) -

Line highlighter handler. This is mainly for syntax highlighting, but in
reality could set the input of the prompt to display anything. The
callback is passed the current line and is expected to return a line that
will be used as the input display.
Note that to set a highlighter, one has to override this function.
Example:

1function hilbish.highlighter(line)  
-2   return line:gsub('"%w+"', function(c) return lunacolors.green(c) end)  
-3end  
-

This code will highlight all double quoted strings in green.

Parameters -

This function has no parameters.


hilbish.hinter(line, pos) +

Replaces the currently running Hilbish instance with the supplied command.
This can be used to do an in-place restart.

Parameters +

string cmd


hilbish.goro(fn) +

Puts fn in a Goroutine.
This can be used to run any function in another thread.
NOTE: THIS FUNCTION MAY CRASH HILBISH IF OUTSIDE VARIABLES ARE ACCESSED.

Parameters +

function fn


hilbish.highlighter(line) +

Line highlighter handler.
This is mainly for syntax highlighting, but in reality could set the input
of the prompt to display anything. The callback is passed the current line
and is expected to return a line that will be used as the input display.
Note that to set a highlighter, one has to override this function.

Parameters +

string line

Example +
1--This code will highlight all double quoted strings in green.
+2function hilbish.highlighter(line)
+3   return line:gsub('"%w+"', function(c) return lunacolors.green(c) end)
+4end
+

hilbish.hinter(line, pos)

The command line hint handler. It gets called on every key insert to
determine what text to use as an inline hint. It is passed the current
line and cursor position. It is expected to return a string which is used
as the text for the hint. This is by default a shim. To set hints,
override this function with your custom handler.

Parameters -

This function has no parameters.


hilbish.inputMode(mode) -

Sets the input mode for Hilbish’s line reader. Accepts either emacs or vim

Parameters -

This function has no parameters.


hilbish.interval(cb, time) -> Timer +

string line

number pos

Example +
1-- this will display "hi" after the cursor in a dimmed color.
+2function hilbish.hinter(line, pos)
+3	return 'hi'
+4end
+

hilbish.inputMode(mode) +

Sets the input mode for Hilbish’s line reader. Accepts either emacs or vim.
emacs is the default. Setting it to vim changes behavior of input to be
Vim-like with modes and Vim keybinds.

Parameters +

string mode


hilbish.interval(cb, time) -> Timer

Runs the cb function every time milliseconds.
This creates a timer that starts immediately.

Parameters -

This function has no parameters.


hilbish.multiprompt(str) -

Changes the continued line prompt to str

Parameters -

This function has no parameters.


hilbish.prependPath(dir) -

Prepends dir to $PATH

Parameters -

This function has no parameters.


hilbish.prompt(str, typ) -

Changes the shell prompt to str
There are a few verbs that can be used in the prompt text.
These will be formatted and replaced with the appropriate values.
%d - Current working directory
%u - Name of current user
%h - Hostname of device

Parameters -

This function has no parameters.


hilbish.read(prompt) -> input (string) -

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 (which shouldn’t happen)

Parameters -

This function has no parameters.


hilbish.run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string) -

Runs cmd in Hilbish’s sh interpreter.
If returnOut is true, the outputs of cmd will be returned as the 2nd and
3rd values instead of being outputted to the terminal.

Parameters -

This function has no parameters.


hilbish.runnerMode(mode) +

function cb

number time


hilbish.multiprompt(str) +

Changes the text prompt when Hilbish asks for more input.
This will show up when text is incomplete, like a missing quote

Parameters +

string str

Example +
 1--[[
+ 2imagine this is your text input:
+ 3user ~ ∆ echo "hey
+ 4
+ 5but there's a missing quote! hilbish will now prompt you so the terminal
+ 6will look like:
+ 7user ~ ∆ echo "hey
+ 8--> ...!"
+ 9
+10so then you get
+11user ~ ∆ echo "hey
+12--> ...!"
+13hey ...!
+14]]--
+15hilbish.multiprompt '-->'
+

hilbish.prependPath(dir) +

Prepends dir to $PATH.

Parameters +

string dir


hilbish.prompt(str, typ) +

Changes the shell prompt to the provided string.
There are a few verbs that can be used in the prompt text.
These will be formatted and replaced with the appropriate values.
%d - Current working directory
%u - Name of current user
%h - Hostname of device

Parameters +

string str

string typ?
Type of prompt, being left or right. Left by default.

Example +
1-- the default hilbish prompt without color
+2hilbish.prompt '%u %d ∆'
+3-- or something of old:
+4hilbish.prompt '%u@%h :%d $'
+5-- prompt: user@hostname: ~/directory $
+

hilbish.read(prompt) -> input (string) +

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 (which shouldn’t happen).

Parameters +

string prompt?


hilbish.run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string) +

Runs cmd in Hilbish’s shell script interpreter.

Parameters +

string cmd

boolean returnOut
If this is true, the function will return the standard output and error of the command instead of printing it.


hilbish.runnerMode(mode)

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.

Parameters -

This function has no parameters.


hilbish.timeout(cb, time) -> Timer -

Runs the cb function after time in milliseconds.
This creates a timer that starts immediately.

Parameters -

This function has no parameters.


hilbish.which(name) -> string +

string|function mode


hilbish.timeout(cb, time) -> Timer +

Runs the cb function after time in milliseconds.
This creates a Timer that starts immediately.

Parameters +

function cb

number time


hilbish.which(name) -> string

Checks if name is a valid command.
Will return the path of the binary, or a basename if it’s a commander.

Parameters -

This function has no parameters.

Types +

string name

Types


Sink

A sink is a structure that has input and/or output to/from a desination.

Methods diff --git a/versions/doc-improvements/docs/api/hilbish/index.xml b/versions/doc-improvements/docs/api/hilbish/index.xml index 9ea6529..0de2f0c 100644 --- a/versions/doc-improvements/docs/api/hilbish/index.xml +++ b/versions/doc-improvements/docs/api/hilbish/index.xml @@ -1,12 +1,14 @@ Module hilbish on Hilbishhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/Recent content in Module hilbish on HilbishHugo -- gohugo.ioen-usModule hilbish.aliaseshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.aliases/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.aliases/Introduction The alias interface deals with all command aliases in Hilbish. -Functions add(alias, cmd) This is an alias (ha) for the hilbish.alias function. delete(name) Removes an alias. list() -&gt; table&lt;string, string&gt; Get a table of all aliases, with string keys as the alias and the value as the command. resolve(alias) -&gt; command (string) Tries to resolve an alias to its command. hilbish.aliases.add(alias, cmd) This is an alias (ha) for the hilbish.Module hilbish.completionhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.completion/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.completion/Introduction The completions interface deals with tab completions. +Functions add(alias, cmd) This is an alias (ha) for the hilbish.alias function. delete(name) Removes an alias. list() -&gt; table[string, string] Get a table of all aliases, with string keys as the alias and the value as the command. resolve(alias) -&gt; string? Resolves an alias to its original command. Will thrown an error if the alias doesn&rsquo;t exist. hilbish.aliases.add(alias, cmd) This is an alias (ha) for the hilbish.Module hilbish.completionhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.completion/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.completion/Introduction The completions interface deals with tab completions. Functions bins(query, ctx, fields) -&gt; entries (table), prefix (string) Return binaries/executables based on the provided parameters. call(name, query, ctx, fields) -&gt; 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) -&gt; entries (table), prefix (string) Returns file matches based on the provided parameters. handler(line, pos) This function contains the general completion handler for Hilbish.Module hilbish.editorhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.editor/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.editor/Introduction The hilbish.editor interface provides functions to directly interact with the line editor in use. -Functions getLine() -&gt; string Returns the current input line. getVimRegister(register) -&gt; string Returns the text that is at the register. insert(text) Inserts text into the line. getChar() -&gt; string Reads a keystroke from the user. This is in a format setVimRegister(register, text) Sets the vim register at register to hold the passed text. hilbish.editor.getLine() -> string Returns the current input line.Module hilbish.historyhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.history/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.history/Introduction The history interface deals with command history. This includes the ability to override functions to change the main method of saving history. -Functions add(cmd) Adds a command to the history. all() -&gt; table Retrieves all history. clear() Deletes all commands from the history. get(idx) Retrieves a command from the history based on the idx. size() -&gt; number Returns the amount of commands in the history. hilbish.history.add(cmd) Adds a command to the history.Module hilbish.jobshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.jobs/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.jobs/Introduction Manage interactive jobs in Hilbish via Lua. +Functions getLine() -&gt; string Returns the current input line. getVimRegister(register) -&gt; string Returns the text that is at the register. insert(text) Inserts text into the Hilbish command line. getChar() -&gt; 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.Module hilbish.historyhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.history/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.history/Introduction The history interface deals with command history. This includes the ability to override functions to change the main method of saving history. +Functions add(cmd) Adds a command to the history. all() -&gt; table Retrieves all history as a table. clear() Deletes all commands from the history. get(index) Retrieves a command from the history based on the index. size() -&gt; number Returns the amount of commands in the history. hilbish.Module hilbish.jobshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.jobs/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.jobs/Introduction 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. -Functions add(cmdstr, args, execPath) Adds a new job to the job table. Note that this does not immediately run it. all() -&gt; table&lt;@Job&gt; Returns a table of all job objects. disown(id) Disowns a job. This deletes it from the job table.Module hilbish.modulehttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.module/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.module/Introduction The hilbish.module interface provides a function to load Hilbish plugins/modules. Hilbish modules are Go-written plugins (see https://pkg.go.dev/plugin ) that are used to add functionality to Hilbish that cannot be written in Lua for any reason. -Note that you don&rsquo;t ever need to use the load function that is here as modules can be loaded with a require call like Lua C modules, and the search paths can be changed with the paths property here.Module hilbish.oshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.os/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.os/ Introduction The os interface provides simple text information properties about the current OS on the systen. This mainly includes the name and version. +Functions add(cmdstr, args, execPath) Creates a new job. This function does not run the job. This function is intended to be all() -&gt; 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.Module hilbish.modulehttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.module/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.module/Introduction The hilbish.module interface provides a function to load Hilbish plugins/modules. Hilbish modules are Go-written plugins (see https://pkg.go.dev/plugin ) that are used to add functionality to Hilbish that cannot be written in Lua for any reason. +Note that you don&rsquo;t ever need to use the load function that is here as modules can be loaded with a require call like Lua C modules, and the search paths can be changed with the paths property here.Module hilbish.oshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.os/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.os/ Introduction Provides simple text information properties about the current operating system. This mainly includes the name and version. Static module fields family Family name of the current OS name Pretty name of the current OS version Version of the current OSModule hilbish.runnerhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.runner/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.runner/Introduction 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 language or script of their choosing. A good example is using it to write command in Fennel. -Functions setMode(cb) This is the same as the hilbish.runnerMode function. It takes a callback, lua(cmd) Evaluates cmd as Lua input. This is the same as using dofile sh(cmd) Runs a command in Hilbish&rsquo;s shell script interpreter.Module hilbish.timershttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.timers/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.timers/Introduction If you ever want to run a piece of code on a timed interval, or want to wait a few seconds, you don&rsquo;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 accessible with doc hilbish). But if you want slightly more control over them, there is the hilbish.timers interface. It allows you to get a timer via ID and control them.Module hilbish.userDirhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.userdir/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.userdir/ Introduction This interface just contains properties to know about certain user directories. It is equivalent to XDG on Linux and gets the user&rsquo;s preferred directories for configs and data. +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&rsquo;s shell script interpreter.Module hilbish.timershttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.timers/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.timers/Introduction If you ever want to run a piece of code on a timed interval, or want to wait a few seconds, you don&rsquo;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 accessible with doc hilbish, or Module hilbish on the Website). +An example of usage: +1local t = hilbish.timers.create(hilbish.timers.TIMEOUT, 5000, function() 2 print &#39;hello!Module hilbish.userDirhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.userdir/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/hilbish/hilbish.userdir/ Introduction This interface just contains properties to know about certain user directories. It is equivalent to XDG on Linux and gets the user&rsquo;s preferred directories for configs and data. Static module fields config The user&rsquo;s config directory data The user&rsquo;s directory for program data \ No newline at end of file diff --git a/versions/doc-improvements/docs/api/index.xml b/versions/doc-improvements/docs/api/index.xml index d41d045..d185627 100644 --- a/versions/doc-improvements/docs/api/index.xml +++ b/versions/doc-improvements/docs/api/index.xml @@ -2,5 +2,5 @@ Usage of the Bait module consists of userstanding event-driven architecture, but it&rsquo;s pretty simple: If you want to act on a certain event, you can catch it. You can act on events via callback functions.Module commanderhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/commander/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/commander/Introduction 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 library in your Hilbish config. 1local commander = require &#39;commander&#39; 2 3commander.register(&#39;hello&#39;, function(args, sinks) 4 sinks.out:writeln &#39;Hello world!&#39; 5end) In this example, a command with the name of hello is created that will print Hello world!Module fshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/fs/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/fs/Introduction The fs module provides filesystem functions to Hilbish. While Lua&rsquo;s standard library has some I/O functions, they&rsquo;re missing a lot of the basics. The fs library offers more functions and will work on any operating system Hilbish does. Functions abs(path) -&gt; string Returns an absolute version of the path. basename(path) -&gt; string Returns the &ldquo;basename,&rdquo; or the last part of the provided path. If path is empty, cd(dir) Changes Hilbish&rsquo;s directory to dir.Module terminalhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/terminal/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/api/terminal/Introduction The terminal library is a simple and lower level library for certain terminal interactions. -Functions restoreState() Restores the last saved state of the terminal saveState() Saves the current state of the terminal setRaw() Puts the terminal in raw mode size() Gets the dimensions of the terminal. Returns a table with width and height terminal.restoreState() Restores the last saved state of the terminal +Functions 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 terminal.restoreState() Restores the last saved state of the terminal Parameters This function has no parameters. \ No newline at end of file diff --git a/versions/doc-improvements/docs/api/terminal/index.html b/versions/doc-improvements/docs/api/terminal/index.html index 8fa0635..29ba3de 100644 --- a/versions/doc-improvements/docs/api/terminal/index.html +++ b/versions/doc-improvements/docs/api/terminal/index.html @@ -3,12 +3,12 @@

Module terminal

low level terminal library

Introduction

The terminal library is a simple and lower level library for certain terminal interactions.

Functions -

restoreState()Restores the last saved state of the terminal
saveState()Saves the current state of the terminal
setRaw()Puts the terminal in raw mode
size()Gets the dimensions of the terminal. Returns a table with width and height

terminal.restoreState() +

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

terminal.restoreState()

Restores the last saved state of the terminal

Parameters

This function has no parameters.


terminal.saveState() -

Saves the current state of the terminal

Parameters +

Saves the current state of the terminal.

Parameters

This function has no parameters.


terminal.setRaw() -

Puts the terminal in raw mode

Parameters +

Puts the terminal into raw mode.

Parameters

This function has no parameters.


terminal.size() -

Gets the dimensions of the terminal. Returns a table with width and height
Note: this is not the size in relation to the dimensions of the display

Parameters +

Gets the dimensions of the terminal. Returns a table with width and height
NOTE: The size refers to the amount of columns and rows of text that can fit in the terminal.

Parameters

This function has no parameters.

\ No newline at end of file diff --git a/versions/doc-improvements/docs/index.xml b/versions/doc-improvements/docs/index.xml index 4515efc..27aa400 100644 --- a/versions/doc-improvements/docs/index.xml +++ b/versions/doc-improvements/docs/index.xml @@ -3,8 +3,8 @@ For simple usage, a single color or style is enough. For example, you can just u In other usage, you may want to use a format string instead of having multiple nested functions for different styles.Frequently Asked Questionshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/faq/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/faq/Is Hilbish POSIX compliant? 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&rsquo;s main goal, but &hellip;.) Windows Support? It compiles for Windows (CI ensures it does), but otherwise it is not directly supported. If you&rsquo;d like to improve this situation, checkout the discussion . Why? Hilbish emerged from the desire of a Lua configured shell.Getting Startedhttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/getting-started/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/getting-started/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. -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.<link>https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/runner-mode/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/runner-mode/</guid><description>Hilbish is unique, when interactive it first attempts to run input as Lua and then tries shell script. But if you&rsquo;re normal, you wouldn&rsquo;t really be using Hilbish anyway but you&rsquo;d also not want this (or maybe want Lua only in some cases.) -The &ldquo;runner mode&rdquo; of Hilbish is customizable via hilbish.runnerMode, which determines how Hilbish will run user input. By default, this is set to hybrid which is the previously mentioned behaviour of running Lua first then going to shell script.</description></item><item><title/><link>https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/timers/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/timers/</guid><description>This has been moved to the hilbish.timers API doc (accessible by doc api hilbish.timers)</description></item><item><title>Completionshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/completions/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/completions/Hilbish has a pretty good completion system. It has a nice looking menu, with 2 types of menus: grid (like file completions) or list. +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.<link>https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/runner-mode/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/runner-mode/</guid><description>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 Hilbish as a REPL. This also allows users to add alternative languages like Fennel as the interactive script runner.</description></item><item><title/><link>https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/timers/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/timers/</guid><description>This has been moved to the hilbish.timers API doc (accessible by doc api hilbish.timers)</description></item><item><title>Completionshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/completions/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/completions/Hilbish has a pretty good completion system. It has a nice looking menu, with 2 types of menus: grid (like file completions) or list. Like most parts of Hilbish, it&rsquo;s made to be extensible and customizable. The default handler for completions in general can be overwritten to provide more advanced completions if needed. Completion Handler By default, it provides 3 things: for the first argument, binaries (with a plain name requested to complete, those in $PATH), files, or command completions.Jobshttps://rosettea.github.io/Hilbish/versions/doc-improvements/docs/jobs/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/versions/doc-improvements/docs/jobs/Hilbish has pretty standard job control. It&rsquo;s missing one or two things, but works well. One thing which is different from other shells (besides Hilbish) itself is the API for jobs, and of course it&rsquo;s in Lua. You can add jobs, stop and delete (disown) them and even get output. Job Interface The job interface refers to hilbish.jobs. diff --git a/versions/doc-improvements/docs/runner-mode/index.html b/versions/doc-improvements/docs/runner-mode/index.html index 0515450..df5ecb1 100644 --- a/versions/doc-improvements/docs/runner-mode/index.html +++ b/versions/doc-improvements/docs/runner-mode/index.html @@ -1,13 +1,17 @@ — Hilbish -