mirror of
https://github.com/Hilbis/Hilbish
synced 2025-06-07 04:52:03 +00:00
326 lines
27 KiB
HTML
326 lines
27 KiB
HTML
<!doctype html>
|
|
<html class="bg-stone-50 dark:bg-neutral-900 text-black dark:text-white"><head><meta content="width=device-width, initial-scale=1.0" name="viewport"><link href="/tailwind.css" rel="stylesheet"><title>Hilbish</title><meta content="#ff89dd" name="theme-color"><meta content="/hilbish-flower.png" property="og:image"><meta content="Hilbish" property="og:title"><meta content="Hilbish" property="og:site_name"><meta content="website" property="og:type"><meta content="Something Unique. Hilbish is the new interactive shell for Lua fans. Extensible, scriptable, configurable: All in Lua." property="og:description"><meta content="Something Unique. Hilbish is the new interactive shell for Lua fans. Extensible, scriptable, configurable: All in Lua." name="description"><meta content="Lua,Shell,Hilbish,Linux,zsh,bash" name="keywords"><meta content property="og:url"></head><body class="min-h-screen flex flex-col"><nav class="flex sticky top-0 w-full z-50 border-b border-b-zinc-300 backdrop-blur-md h-12"><div class="flex my-auto px-2"><div><a class="flex items-center gap-1" href="/"><img class="h-6" src="/hilbish-flower.png"><span class="self-center text-2xl">Hilbish</span></a></div></div></nav><div class="flex flex-col"><div class="h-10 flex py-2 px-4 border-b border-b-zinc-300 w-full gap-2 backdrop-blur-sm bg-zinc-300/50 dark:bg-zinc-800/50 z-50"><label class="cursor-pointer" for="sidebar-toggle"><tag><svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" class="fill-black"><path d="M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"/></svg></tag></label><span>Module hilbish</span></div><div class="grid"><input class="peer hidden" id="sidebar-toggle" type="checkbox"><div class="border-r border-r-zinc-300 col-start-1 row-start-1 sticky top-22 sm:top-12 h-full sm:h-svh bg-neutral-200 dark:bg-neutral-900 basis-3/5 transition-transform duration-300 -translate-x-full peer-checked:translate-x-0 z-30"><div class="p-4 -mb-4 overflow-y-auto h-full"><h2 class="text-xl font-semibold mb-4">Sidebar</h2><ul><li class="mb-2">Vim Mode</li><li class="mb-2">Completions</li><li class="mb-2">Lunacolors</li><li class="mb-2">Frequently Asked Questions</li><li class="mb-2">Getting Started</li><li class="mb-2">Introduction</li><li class="mb-2">Module hilbish</li><li class="mb-2">Module fs</li><li class="mb-2">Module snail</li><li class="mb-2">Module terminal</li><li class="mb-2">Module commander</li><li class="mb-2">API</li><li class="mb-2">Module bait</li><li class="mb-2">Module hilbish.module</li><li class="mb-2">Module hilbish.abbr</li><li class="mb-2">Module hilbish.userDir</li><li class="mb-2">Module hilbish.os</li><li class="mb-2">Module hilbish.history</li><li class="mb-2">Module hilbish.completion</li><li class="mb-2">Module hilbish.messages</li><li class="mb-2">Module hilbish.aliases</li><li class="mb-2">Module hilbish.runner</li><li class="mb-2">Module hilbish.timers</li><li class="mb-2">Module hilbish</li><li class="mb-2">Module hilbish.jobs</li><li class="mb-2">Module hilbish.editor</li><li class="mb-2">Actions</li><li class="mb-2">Module doc</li><li class="mb-2">Nature</li><li class="mb-2">Module dirs</li><li class="mb-2">Hilbish</li><li class="mb-2">Command</li><li class="mb-2">Signals</li><li class="mb-2">Signal</li><li class="mb-2">Notification</li><li class="mb-2">Runner Mode</li><li class="mb-2">Options</li><li class="mb-2">Features</li></ul></div></div><main class="col-start-1 row-start-1 transition-all duration-300 peer-checked:filter peer-checked:blur-sm peer-checked:bg-black/30 px-4 pt-2"><h1 class="font-bold text-4xl">Module hilbish</h1><h2 class="font-bold text-3xl" id="Introduction-The-Hilbish-module-includes-the-core-API-containing-interfaces-and-functions-which-directly-relate-to-shell-functionality.">Introduction
|
|
The Hilbish module includes the core API, containing
|
|
interfaces and functions which directly relate to shell functionality.</h2><h2 class="font-bold text-3xl" id="Functions-|||-|----|----|-|<a-href="alias">alias(cmd-orig)</a>|Sets-an-alias-with-a-name-of-cmd-to-another-command.|-|<a-href="appendPath">appendPath(dir)</a>|Appends-the-provided-dir-to-the-command-path-($PATH)|-|<a-href="complete">complete(scope-cb)</a>|Registers-a-completion-handler-for-the-specified-scope.|-|<a-href="cwd">cwd()-->-string</a>|Returns-the-current-directory-of-the-shell.|-|<a-href="exec">exec(cmd)</a>|Replaces-the-currently-running-Hilbish-instance-with-the-supplied-command.|-|<a-href="goro">goro(fn)</a>|Puts-fn-in-a-Goroutine.|-|<a-href="highlighter">highlighter(line)</a>|Line-highlighter-handler.|-|<a-href="hinter">hinter(line-pos)</a>|The-command-line-hint-handler.-It-gets-called-on-every-key-insert-to|-|<a-href="inputMode">inputMode(mode)</a>|Sets-the-input-mode-for-Hilbish's-line-reader.|-|<a-href="interval">interval(cb-time)-->-@Timer</a>|Runs-the-cb-function-every-specified-amount-of-time.|-|<a-href="multiprompt">multiprompt(str)</a>|Changes-the-text-prompt-when-Hilbish-asks-for-more-input.|-|<a-href="prependPath">prependPath(dir)</a>|Prepends-dir-to-$PATH.|-|<a-href="prompt">prompt(str-typ)</a>|Changes-the-shell-prompt-to-the-provided-string.|-|<a-href="read">read(prompt)-->-input-(string)</a>|Read-input-from-the-user-using-Hilbish's-line-editor/input-reader.|-|<a-href="timeout">timeout(cb-time)-->-@Timer</a>|Executed-the-cb-function-after-a-period-of-time.|-|<a-href="which">which(name)-->-string</a>|Checks-if-name-is-a-valid-command.|-|<a-href="runnerMode">runnerMode(mode)</a>|Sets-the-execution/runner-mode-for-interactive-Hilbish.|-|<a-href="run">run(cmd-streams)</a>|Runs-cmd-in-Hilbish's-shell-script-interpreter.|">Functions
|
|
|||
|
|
|----|----|
|
|
|<a href="#alias">alias(cmd, orig)</a>|Sets an alias, with a name of <code>cmd</code> to another command.|
|
|
|<a href="#appendPath">appendPath(dir)</a>|Appends the provided dir to the command path (<code>$PATH</code>)|
|
|
|<a href="#complete">complete(scope, cb)</a>|Registers a completion handler for the specified scope.|
|
|
|<a href="#cwd">cwd() -> string</a>|Returns the current directory of the shell.|
|
|
|<a href="#exec">exec(cmd)</a>|Replaces the currently running Hilbish instance with the supplied command.|
|
|
|<a href="#goro">goro(fn)</a>|Puts <code>fn</code> in a Goroutine.|
|
|
|<a href="#highlighter">highlighter(line)</a>|Line highlighter handler.|
|
|
|<a href="#hinter">hinter(line, pos)</a>|The command line hint handler. It gets called on every key insert to|
|
|
|<a href="#inputMode">inputMode(mode)</a>|Sets the input mode for Hilbish's line reader.|
|
|
|<a href="#interval">interval(cb, time) -> @Timer</a>|Runs the <code>cb</code> function every specified amount of <code>time</code>.|
|
|
|<a href="#multiprompt">multiprompt(str)</a>|Changes the text prompt when Hilbish asks for more input.|
|
|
|<a href="#prependPath">prependPath(dir)</a>|Prepends <code>dir</code> to $PATH.|
|
|
|<a href="#prompt">prompt(str, typ)</a>|Changes the shell prompt to the provided string.|
|
|
|<a href="#read">read(prompt) -> input (string)</a>|Read input from the user, using Hilbish's line editor/input reader.|
|
|
|<a href="#timeout">timeout(cb, time) -> @Timer</a>|Executed the <code>cb</code> function after a period of <code>time</code>.|
|
|
|<a href="#which">which(name) -> string</a>|Checks if <code>name</code> is a valid command.|
|
|
|<a href="#runnerMode">runnerMode(mode)</a>|Sets the execution/runner mode for interactive Hilbish.|
|
|
|<a href="#run">run(cmd, streams)</a>|Runs <code>cmd</code> in Hilbish's shell script interpreter.|</h2><h2 class="font-bold text-3xl" id="Static-module-fields-|||-|----|----|-|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|">Static module fields
|
|
|||
|
|
|----|----|
|
|
|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|</h2><p><hr>
|
|
<div id='alias'>
|
|
<h4 class='heading'>
|
|
hilbish.alias(cmd, orig)
|
|
<a href="#alias" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Sets an alias, with a name of <code>cmd</code> to another command. </p><p class="font-bold text-xl" id="Parameters-string-**cmd**---Name-of-the-alias">Parameters
|
|
<code>string</code> **<code>cmd</code>**
|
|
Name of the alias</p><p><code>string</code> **<code>orig</code>**
|
|
Command that will be aliased</p><p class="font-bold text-xl" id="Example-lua----With-this-"ga-file"-will-turn-into-"git-add-file"-hilbish.alias('ga'-'git-add')">Example
|
|
<code>lua
|
|
-- With this, "ga file" will turn into "git add file"
|
|
hilbish.alias('ga', 'git add')</code></p><p>-- Numbered substitutions are supported here!
|
|
hilbish.alias('dircount', 'ls %1 | wc -l')
|
|
-- "dircount ~" would count how many files are in ~ (home directory).
|
|
<code>
|
|
</div></code></p><p><hr>
|
|
<div id='appendPath'>
|
|
<h4 class='heading'>
|
|
hilbish.appendPath(dir)
|
|
<a href="#appendPath" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Appends the provided dir to the command path (<code>$PATH</code>) </p><p class="font-bold text-xl" id="Parameters-string|table-**dir**---Directory-(or-directories)-to-append-to-path">Parameters
|
|
<code>string|table</code> **<code>dir</code>**
|
|
Directory (or directories) to append to path</p><p class="font-bold text-xl" id="Example-lua-hilbish.appendPath-'~/go/bin'----Will-add-~/go/bin-to-the-command-path.">Example
|
|
<code>lua
|
|
hilbish.appendPath '~/go/bin'
|
|
-- Will add ~/go/bin to the command path.</code></p><p>-- Or do multiple:
|
|
hilbish.appendPath {
|
|
'~/go/bin',
|
|
'~/.local/bin'
|
|
}
|
|
<code>
|
|
</div></code></p><p><hr>
|
|
<div id='complete'>
|
|
<h4 class='heading'>
|
|
hilbish.complete(scope, cb)
|
|
<a href="#complete" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Registers a completion handler for the specified scope.
|
|
A <code>scope</code> is expected to be <code>command.<cmd></code>,
|
|
replacing <cmd> with the name of the command (for example <code>command.git</code>).
|
|
The documentation for completions, under Features/Completions or <code>doc completions</code>
|
|
provides more details. </p><p class="font-bold text-xl" id="Parameters-string-**scope**">Parameters
|
|
<code>string</code> **<code>scope</code>** </p><p><code>function</code> **<code>cb</code>** </p><p class="font-bold text-xl" id="Example-lua----This-is-a-very-simple-example.-Read-the-full-doc-for-completions-for-details.-hilbish.complete('command.sudo'-function(query-ctx-fields)- if-fields-==-0-then- ---complete-for-commands- local-comps-pfx-=-hilbish.completion.bins(query-ctx-fields)- local-compGroup-=-{- items-=-comps----our-list-of-items-to-complete- type-=-'grid'----what-our-completions-will-look-like.- }">Example
|
|
<code>lua
|
|
-- This is a very simple example. Read the full doc for completions for details.
|
|
hilbish.complete('command.sudo', function(query, ctx, fields)
|
|
if #fields == 0 then
|
|
-- complete for commands
|
|
local comps, pfx = hilbish.completion.bins(query, ctx, fields)
|
|
local compGroup = {
|
|
items = comps, -- our list of items to complete
|
|
type = 'grid' -- what our completions will look like.
|
|
}</code></p><p> return {compGroup}, pfx
|
|
end</p><p> -- otherwise just be boring and return files</p><p> local comps, pfx = hilbish.completion.files(query, ctx, fields)
|
|
local compGroup = {
|
|
items = comps,
|
|
type = 'grid'
|
|
}</p><p> return {compGroup}, pfx
|
|
end)
|
|
<code>
|
|
</div></code></p><p><hr>
|
|
<div id='cwd'>
|
|
<h4 class='heading'>
|
|
hilbish.cwd() -> string
|
|
<a href="#cwd" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Returns the current directory of the shell. </p><p class="font-bold text-xl" id="Parameters-This-function-has-no-parameters.---</div>">Parameters
|
|
This function has no parameters.
|
|
</div></p><p><hr>
|
|
<div id='exec'>
|
|
<h4 class='heading'>
|
|
hilbish.exec(cmd)
|
|
<a href="#exec" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Replaces the currently running Hilbish instance with the supplied command.
|
|
This can be used to do an in-place restart. </p><p class="font-bold text-xl" id="Parameters-string-**cmd**">Parameters
|
|
<code>string</code> **<code>cmd</code>** </p><p></div></p><p><hr>
|
|
<div id='goro'>
|
|
<h4 class='heading'>
|
|
hilbish.goro(fn)
|
|
<a href="#goro" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Puts <code>fn</code> in a Goroutine.
|
|
This can be used to run any function in another thread at the same time as other Lua code.
|
|
*<strong>NOTE: THIS FUNCTION MAY CRASH HILBISH IF OUTSIDE VARIABLES ARE ACCESSED.</strong>*
|
|
*<strong>This is a limitation of the Lua runtime.</strong>* </p><p class="font-bold text-xl" id="Parameters-function-**fn**">Parameters
|
|
<code>function</code> **<code>fn</code>** </p><p></div></p><p><hr>
|
|
<div id='highlighter'>
|
|
<h4 class='heading'>
|
|
hilbish.highlighter(line)
|
|
<a href="#highlighter" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Line highlighter handler.
|
|
This is mainly for syntax highlighting, but in reality could set the input
|
|
of the prompt to <strong>display</strong> 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. </p><p class="font-bold text-xl" id="Parameters-string-**line**">Parameters
|
|
<code>string</code> **<code>line</code>** </p><p class="font-bold text-xl" id="Example-lua---This-code-will-highlight-all-double-quoted-strings-in-green.-function-hilbish.highlighter(line)----return-line:gsub('"%w+"'-function(c)-return-lunacolors.green(c)-end)-end--</div>">Example
|
|
<code>lua
|
|
--This code will highlight all double quoted strings in green.
|
|
function hilbish.highlighter(line)
|
|
return line:gsub('"%w+"', function(c) return lunacolors.green(c) end)
|
|
end
|
|
</code>
|
|
</div></p><p><hr>
|
|
<div id='hinter'>
|
|
<h4 class='heading'>
|
|
hilbish.hinter(line, pos)
|
|
<a href="#hinter" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>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. </p><p class="font-bold text-xl">Parameters
|
|
<code>string</code> **<code>line</code>** </p><p><code>number</code> **<code>pos</code>**
|
|
Position of cursor in line. Usually equals string.len(line)</p><p class="font-bold text-xl" id="Example-lua----this-will-display-"hi"-after-the-cursor-in-a-dimmed-color.-function-hilbish.hinter(line-pos)- return-'hi'-end--</div>">Example
|
|
<code>lua
|
|
-- this will display "hi" after the cursor in a dimmed color.
|
|
function hilbish.hinter(line, pos)
|
|
return 'hi'
|
|
end
|
|
</code>
|
|
</div></p><p><hr>
|
|
<div id='inputMode'>
|
|
<h4 class='heading'>
|
|
hilbish.inputMode(mode)
|
|
<a href="#inputMode" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Sets the input mode for Hilbish's line reader.
|
|
<code>emacs</code> is the default. Setting it to <code>vim</code> changes behavior of input to be
|
|
Vim-like with modes and Vim keybinds. </p><p class="font-bold text-xl" id="Parameters-string-**mode**---Can-be-set-to-either-emacs-or-vim">Parameters
|
|
<code>string</code> **<code>mode</code>**
|
|
Can be set to either <code>emacs</code> or <code>vim</code></p><p></div></p><p><hr>
|
|
<div id='interval'>
|
|
<h4 class='heading'>
|
|
hilbish.interval(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
|
<a href="#interval" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Runs the <code>cb</code> function every specified amount of <code>time</code>.
|
|
This creates a timer that ticking immediately. </p><p class="font-bold text-xl" id="Parameters-function-**cb**">Parameters
|
|
<code>function</code> **<code>cb</code>** </p><p><code>number</code> **<code>time</code>**
|
|
Time in milliseconds.</p><p></div></p><p><hr>
|
|
<div id='multiprompt'>
|
|
<h4 class='heading'>
|
|
hilbish.multiprompt(str)
|
|
<a href="#multiprompt" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Changes the text prompt when Hilbish asks for more input.
|
|
This will show up when text is incomplete, like a missing quote </p><p class="font-bold text-xl" id="Parameters-string-**str**">Parameters
|
|
<code>string</code> **<code>str</code>** </p><p class="font-bold text-xl" id="Example-lua---[[-imagine-this-is-your-text-input:-user-~-∆-echo-"hey">Example
|
|
<code>lua
|
|
--[[
|
|
imagine this is your text input:
|
|
user ~ ∆ echo "hey</code></p><p>but there's a missing quote! hilbish will now prompt you so the terminal
|
|
will look like:
|
|
user ~ ∆ echo "hey
|
|
--> ...!"</p><p>so then you get
|
|
user ~ ∆ echo "hey
|
|
--> ...!"
|
|
hey ...!
|
|
]]--
|
|
hilbish.multiprompt '-->'
|
|
<code>
|
|
</div></code></p><p><hr>
|
|
<div id='prependPath'>
|
|
<h4 class='heading'>
|
|
hilbish.prependPath(dir)
|
|
<a href="#prependPath" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Prepends <code>dir</code> to $PATH. </p><p class="font-bold text-xl" id="Parameters-string-**dir**">Parameters
|
|
<code>string</code> **<code>dir</code>** </p><p></div></p><p><hr>
|
|
<div id='prompt'>
|
|
<h4 class='heading'>
|
|
hilbish.prompt(str, typ)
|
|
<a href="#prompt" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>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.
|
|
<code>%d</code> - Current working directory
|
|
<code>%u</code> - Name of current user
|
|
<code>%h</code> - Hostname of device </p><p class="font-bold text-xl">Parameters
|
|
<code>string</code> **<code>str</code>** </p><p><code>string</code> **<code>typ?</code>**
|
|
Type of prompt, being left or right. Left by default.</p><p class="font-bold text-xl" id="Example-lua----the-default-hilbish-prompt-without-color-hilbish.prompt-'%u-%d-∆'----or-something-of-old:-hilbish.prompt-'%u@%h-:%d-$'----prompt:-user@hostname:-~/directory-$--</div>">Example
|
|
<code>lua
|
|
-- the default hilbish prompt without color
|
|
hilbish.prompt '%u %d ∆'
|
|
-- or something of old:
|
|
hilbish.prompt '%u@%h :%d $'
|
|
-- prompt: user@hostname: ~/directory $
|
|
</code>
|
|
</div></p><p><hr>
|
|
<div id='read'>
|
|
<h4 class='heading'>
|
|
hilbish.read(prompt) -> input (string)
|
|
<a href="#read" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Read input from the user, using Hilbish's line editor/input reader.
|
|
This is a separate instance from the one Hilbish actually uses.
|
|
Returns <code>input</code>, will be nil if Ctrl-D is pressed, or an error occurs. </p><p class="font-bold text-xl" id="Parameters-string-**prompt**---Text-to-print-before-input-can-be-empty.">Parameters
|
|
<code>string</code> **<code>prompt?</code>**
|
|
Text to print before input, can be empty.</p><p></div></p><p><hr>
|
|
<div id='timeout'>
|
|
<h4 class='heading'>
|
|
hilbish.timeout(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
|
|
<a href="#timeout" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Executed the <code>cb</code> function after a period of <code>time</code>.
|
|
This creates a Timer that starts ticking immediately. </p><p class="font-bold text-xl">Parameters
|
|
<code>function</code> **<code>cb</code>** </p><p><code>number</code> **<code>time</code>**
|
|
Time to run in milliseconds.</p><p></div></p><p><hr>
|
|
<div id='which'>
|
|
<h4 class='heading'>
|
|
hilbish.which(name) -> string
|
|
<a href="#which" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Checks if <code>name</code> is a valid command.
|
|
Will return the path of the binary, or a basename if it's a commander. </p><p class="font-bold text-xl" id="Parameters-string-**name**">Parameters
|
|
<code>string</code> **<code>name</code>** </p><p></div></p><h2 class="font-bold text-3xl" id="Types-<hr>">Types
|
|
<hr></h2><h2 class="font-bold text-3xl" id="Sink-A-sink-is-a-structure-that-has-input-and/or-output-to/from-a-desination.">Sink
|
|
A sink is a structure that has input and/or output to/from a desination.</h2><h3 class="font-bold text-2xl" id="Methods">Methods</h3><p class="font-bold text-xl" id="autoFlush(auto)-Sets/toggles-the-option-of-automatically-flushing-output.-A-call-with-no-argument-will-toggle-the-value.">autoFlush(auto)
|
|
Sets/toggles the option of automatically flushing output.
|
|
A call with no argument will toggle the value.</p><p class="font-bold text-xl" id="flush()-Flush-writes-all-buffered-input-to-the-sink.">flush()
|
|
Flush writes all buffered input to the sink.</p><p class="font-bold text-xl" id="read()-->-string-Reads-a-liine-of-input-from-the-sink.">read() -> string
|
|
Reads a liine of input from the sink.</p><p class="font-bold text-xl" id="readAll()-->-string-Reads-all-input-from-the-sink.">readAll() -> string
|
|
Reads all input from the sink.</p><p class="font-bold text-xl" id="write(str)-Writes-data-to-a-sink.">write(str)
|
|
Writes data to a sink.</p><p class="font-bold text-xl" id="writeln(str)-Writes-data-to-a-sink-with-a-newline-at-the-end.">writeln(str)
|
|
Writes data to a sink with a newline at the end.</p><p><hr>
|
|
<div id='run'>
|
|
<h4 class='heading'>
|
|
hilbish.run(cmd, streams)
|
|
<a href="#run" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Runs <code>cmd</code> in Hilbish's shell script interpreter.
|
|
The <code>streams</code> 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 <code>out</code>, <code>err</code>, and <code>input</code> respectively.
|
|
As a boolean, it specifies whether the command should use standard output or return its output streams.
|
|
#### Parameters
|
|
<code>cmd</code> **<code>string</code>** </p><p><code>streams</code> **<code>table|boolean</code>** </p><p class="font-bold text-xl" id="Example-lua----This-code-is-the-same-as-`ls--l-|-wc--l`-local-fs-=-require-'fs'-local-pr-pw-=-fs.pipe()-hilbish.run('ls--l'-{- stdout-=-pw- stderr-=-pw-})-pw:close()-hilbish.run('wc--l'-{- stdin-=-pr-})--</div>">Example
|
|
<code>lua
|
|
-- This code is the same as `ls -l | wc -l`
|
|
local fs = require 'fs'
|
|
local pr, pw = fs.pipe()
|
|
hilbish.run('ls -l', {
|
|
stdout = pw,
|
|
stderr = pw,
|
|
})
|
|
pw:close()
|
|
hilbish.run('wc -l', {
|
|
stdin = pr
|
|
})
|
|
</code>
|
|
</div></p><p><hr>
|
|
<div id='runnerMode'>
|
|
<h4 class='heading'>
|
|
hilbish.runnerMode(mode)
|
|
<a href="#runnerMode" class='heading-link'>
|
|
<i class="fas fa-paperclip"></i>
|
|
</a>
|
|
</h4></p><p>Sets the execution/runner mode for interactive Hilbish.
|
|
*<strong>NOTE: This function is deprecated and will be removed in 3.0</strong>*
|
|
Use <code>hilbish.runner.setCurrent</code> 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 <a href="../features/runner-mode">about runner mode</a> for more information.
|
|
#### Parameters
|
|
<code>mode</code> **<code>string|function</code>** </p><p></div></p></main></div></div><footer class="py-4 px-6 flex flex-row justify-around border-t border-t-zinc-300"><div class="flex flex-col"><a class="flex items-center gap-1" href><img class="h-24" src="/hilbish-flower.png"><span class="self-center text-6xl">Hilbish</span></a><span class="text-xl">The Moon-powered shell!</span><span class="text-light text-neutral-500">MIT License, copyright sammyette 2025</span></div><div class="flex flex-col"><a href="https://github.com/Rosettea/Hilbish"><span class="text-pink-300 text-light">GitHub</span></a></div></footer></body></html> |