2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-06-07 04:52:03 +00:00

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-|||-|----|----|-|&lt;a-href=&quot;alias&quot;&gt;alias(cmd-orig)&lt;/a&gt;|Sets-an-alias-with-a-name-of-cmd-to-another-command.|-|&lt;a-href=&quot;appendPath&quot;&gt;appendPath(dir)&lt;/a&gt;|Appends-the-provided-dir-to-the-command-path-($PATH)|-|&lt;a-href=&quot;complete&quot;&gt;complete(scope-cb)&lt;/a&gt;|Registers-a-completion-handler-for-the-specified-scope.|-|&lt;a-href=&quot;cwd&quot;&gt;cwd()--&gt;-string&lt;/a&gt;|Returns-the-current-directory-of-the-shell.|-|&lt;a-href=&quot;exec&quot;&gt;exec(cmd)&lt;/a&gt;|Replaces-the-currently-running-Hilbish-instance-with-the-supplied-command.|-|&lt;a-href=&quot;goro&quot;&gt;goro(fn)&lt;/a&gt;|Puts-fn-in-a-Goroutine.|-|&lt;a-href=&quot;highlighter&quot;&gt;highlighter(line)&lt;/a&gt;|Line-highlighter-handler.|-|&lt;a-href=&quot;hinter&quot;&gt;hinter(line-pos)&lt;/a&gt;|The-command-line-hint-handler.-It-gets-called-on-every-key-insert-to|-|&lt;a-href=&quot;inputMode&quot;&gt;inputMode(mode)&lt;/a&gt;|Sets-the-input-mode-for-Hilbish&#39;s-line-reader.|-|&lt;a-href=&quot;interval&quot;&gt;interval(cb-time)--&gt;-@Timer&lt;/a&gt;|Runs-the-cb-function-every-specified-amount-of-time.|-|&lt;a-href=&quot;multiprompt&quot;&gt;multiprompt(str)&lt;/a&gt;|Changes-the-text-prompt-when-Hilbish-asks-for-more-input.|-|&lt;a-href=&quot;prependPath&quot;&gt;prependPath(dir)&lt;/a&gt;|Prepends-dir-to-$PATH.|-|&lt;a-href=&quot;prompt&quot;&gt;prompt(str-typ)&lt;/a&gt;|Changes-the-shell-prompt-to-the-provided-string.|-|&lt;a-href=&quot;read&quot;&gt;read(prompt)--&gt;-input-(string)&lt;/a&gt;|Read-input-from-the-user-using-Hilbish&#39;s-line-editor/input-reader.|-|&lt;a-href=&quot;timeout&quot;&gt;timeout(cb-time)--&gt;-@Timer&lt;/a&gt;|Executed-the-cb-function-after-a-period-of-time.|-|&lt;a-href=&quot;which&quot;&gt;which(name)--&gt;-string&lt;/a&gt;|Checks-if-name-is-a-valid-command.|-|&lt;a-href=&quot;runnerMode&quot;&gt;runnerMode(mode)&lt;/a&gt;|Sets-the-execution/runner-mode-for-interactive-Hilbish.|-|&lt;a-href=&quot;run&quot;&gt;run(cmd-streams)&lt;/a&gt;|Runs-cmd-in-Hilbish&#39;s-shell-script-interpreter.|">Functions
|||
|----|----|
|&lt;a href=&quot;#alias&quot;&gt;alias(cmd, orig)&lt;/a&gt;|Sets an alias, with a name of <code>cmd</code> to another command.|
|&lt;a href=&quot;#appendPath&quot;&gt;appendPath(dir)&lt;/a&gt;|Appends the provided dir to the command path (<code>$PATH</code>)|
|&lt;a href=&quot;#complete&quot;&gt;complete(scope, cb)&lt;/a&gt;|Registers a completion handler for the specified scope.|
|&lt;a href=&quot;#cwd&quot;&gt;cwd() -&gt; string&lt;/a&gt;|Returns the current directory of the shell.|
|&lt;a href=&quot;#exec&quot;&gt;exec(cmd)&lt;/a&gt;|Replaces the currently running Hilbish instance with the supplied command.|
|&lt;a href=&quot;#goro&quot;&gt;goro(fn)&lt;/a&gt;|Puts <code>fn</code> in a Goroutine.|
|&lt;a href=&quot;#highlighter&quot;&gt;highlighter(line)&lt;/a&gt;|Line highlighter handler.|
|&lt;a href=&quot;#hinter&quot;&gt;hinter(line, pos)&lt;/a&gt;|The command line hint handler. It gets called on every key insert to|
|&lt;a href=&quot;#inputMode&quot;&gt;inputMode(mode)&lt;/a&gt;|Sets the input mode for Hilbish&#39;s line reader.|
|&lt;a href=&quot;#interval&quot;&gt;interval(cb, time) -&gt; @Timer&lt;/a&gt;|Runs the <code>cb</code> function every specified amount of <code>time</code>.|
|&lt;a href=&quot;#multiprompt&quot;&gt;multiprompt(str)&lt;/a&gt;|Changes the text prompt when Hilbish asks for more input.|
|&lt;a href=&quot;#prependPath&quot;&gt;prependPath(dir)&lt;/a&gt;|Prepends <code>dir</code> to $PATH.|
|&lt;a href=&quot;#prompt&quot;&gt;prompt(str, typ)&lt;/a&gt;|Changes the shell prompt to the provided string.|
|&lt;a href=&quot;#read&quot;&gt;read(prompt) -&gt; input (string)&lt;/a&gt;|Read input from the user, using Hilbish&#39;s line editor/input reader.|
|&lt;a href=&quot;#timeout&quot;&gt;timeout(cb, time) -&gt; @Timer&lt;/a&gt;|Executed the <code>cb</code> function after a period of <code>time</code>.|
|&lt;a href=&quot;#which&quot;&gt;which(name) -&gt; string&lt;/a&gt;|Checks if <code>name</code> is a valid command.|
|&lt;a href=&quot;#runnerMode&quot;&gt;runnerMode(mode)&lt;/a&gt;|Sets the execution/runner mode for interactive Hilbish.|
|&lt;a href=&quot;#run&quot;&gt;run(cmd, streams)&lt;/a&gt;|Runs <code>cmd</code> in Hilbish&#39;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>&lt;hr&gt;
&lt;div id=&#39;alias&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.alias(cmd, orig)
&lt;a href=&quot;#alias&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</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-&quot;ga-file&quot;-will-turn-into-&quot;git-add-file&quot;-hilbish.alias(&#39;ga&#39;-&#39;git-add&#39;)">Example
<code>lua
-- With this, &quot;ga file&quot; will turn into &quot;git add file&quot;
hilbish.alias(&#39;ga&#39;, &#39;git add&#39;)</code></p><p>-- Numbered substitutions are supported here!
hilbish.alias(&#39;dircount&#39;, &#39;ls %1 | wc -l&#39;)
-- &quot;dircount ~&quot; would count how many files are in ~ (home directory).
<code>
&lt;/div&gt;</code></p><p>&lt;hr&gt;
&lt;div id=&#39;appendPath&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.appendPath(dir)
&lt;a href=&quot;#appendPath&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</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-&#39;~/go/bin&#39;----Will-add-~/go/bin-to-the-command-path.">Example
<code>lua
hilbish.appendPath &#39;~/go/bin&#39;
-- Will add ~/go/bin to the command path.</code></p><p>-- Or do multiple:
hilbish.appendPath {
&#39;~/go/bin&#39;,
&#39;~/.local/bin&#39;
}
<code>
&lt;/div&gt;</code></p><p>&lt;hr&gt;
&lt;div id=&#39;complete&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.complete(scope, cb)
&lt;a href=&quot;#complete&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</p><p>Registers a completion handler for the specified scope.
A <code>scope</code> is expected to be <code>command.&lt;cmd&gt;</code>,
replacing &lt;cmd&gt; 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(&#39;command.sudo&#39;-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-=-&#39;grid&#39;----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(&#39;command.sudo&#39;, 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 = &#39;grid&#39; -- 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 = &#39;grid&#39;
}</p><p> return {compGroup}, pfx
end)
<code>
&lt;/div&gt;</code></p><p>&lt;hr&gt;
&lt;div id=&#39;cwd&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.cwd() -&gt; string
&lt;a href=&quot;#cwd&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</p><p>Returns the current directory of the shell. </p><p class="font-bold text-xl" id="Parameters-This-function-has-no-parameters.---&lt;/div&gt;">Parameters
This function has no parameters.
&lt;/div&gt;</p><p>&lt;hr&gt;
&lt;div id=&#39;exec&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.exec(cmd)
&lt;a href=&quot;#exec&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</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>&lt;/div&gt;</p><p>&lt;hr&gt;
&lt;div id=&#39;goro&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.goro(fn)
&lt;a href=&quot;#goro&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</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>&lt;/div&gt;</p><p>&lt;hr&gt;
&lt;div id=&#39;highlighter&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.highlighter(line)
&lt;a href=&quot;#highlighter&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</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(&#39;&quot;%w+&quot;&#39;-function(c)-return-lunacolors.green(c)-end)-end--&lt;/div&gt;">Example
<code>lua
--This code will highlight all double quoted strings in green.
function hilbish.highlighter(line)
return line:gsub(&#39;&quot;%w+&quot;&#39;, function(c) return lunacolors.green(c) end)
end
</code>
&lt;/div&gt;</p><p>&lt;hr&gt;
&lt;div id=&#39;hinter&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.hinter(line, pos)
&lt;a href=&quot;#hinter&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</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-&quot;hi&quot;-after-the-cursor-in-a-dimmed-color.-function-hilbish.hinter(line-pos)- return-&#39;hi&#39;-end--&lt;/div&gt;">Example
<code>lua
-- this will display &quot;hi&quot; after the cursor in a dimmed color.
function hilbish.hinter(line, pos)
return &#39;hi&#39;
end
</code>
&lt;/div&gt;</p><p>&lt;hr&gt;
&lt;div id=&#39;inputMode&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.inputMode(mode)
&lt;a href=&quot;#inputMode&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</p><p>Sets the input mode for Hilbish&#39;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>&lt;/div&gt;</p><p>&lt;hr&gt;
&lt;div id=&#39;interval&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.interval(cb, time) -&gt; &lt;a href=&quot;/Hilbish/docs/api/hilbish/hilbish.timers/#timer&quot; style=&quot;text-decoration: none;&quot; id=&quot;lol&quot;&gt;Timer&lt;/a&gt;
&lt;a href=&quot;#interval&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</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>&lt;/div&gt;</p><p>&lt;hr&gt;
&lt;div id=&#39;multiprompt&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.multiprompt(str)
&lt;a href=&quot;#multiprompt&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</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-&quot;hey">Example
<code>lua
--[[
imagine this is your text input:
user ~ ∆ echo &quot;hey</code></p><p>but there&#39;s a missing quote! hilbish will now prompt you so the terminal
will look like:
user ~ ∆ echo &quot;hey
--&gt; ...!&quot;</p><p>so then you get
user ~ ∆ echo &quot;hey
--&gt; ...!&quot;
hey ...!
]]--
hilbish.multiprompt &#39;--&gt;&#39;
<code>
&lt;/div&gt;</code></p><p>&lt;hr&gt;
&lt;div id=&#39;prependPath&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.prependPath(dir)
&lt;a href=&quot;#prependPath&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</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>&lt;/div&gt;</p><p>&lt;hr&gt;
&lt;div id=&#39;prompt&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.prompt(str, typ)
&lt;a href=&quot;#prompt&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</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-&#39;%u-%d-∆&#39;----or-something-of-old:-hilbish.prompt-&#39;%u@%h-:%d-$&#39;----prompt:-user@hostname:-~/directory-$--&lt;/div&gt;">Example
<code>lua
-- the default hilbish prompt without color
hilbish.prompt &#39;%u %d ∆&#39;
-- or something of old:
hilbish.prompt &#39;%u@%h :%d $&#39;
-- prompt: user@hostname: ~/directory $
</code>
&lt;/div&gt;</p><p>&lt;hr&gt;
&lt;div id=&#39;read&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.read(prompt) -&gt; input (string)
&lt;a href=&quot;#read&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</p><p>Read input from the user, using Hilbish&#39;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>&lt;/div&gt;</p><p>&lt;hr&gt;
&lt;div id=&#39;timeout&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.timeout(cb, time) -&gt; &lt;a href=&quot;/Hilbish/docs/api/hilbish/hilbish.timers/#timer&quot; style=&quot;text-decoration: none;&quot; id=&quot;lol&quot;&gt;Timer&lt;/a&gt;
&lt;a href=&quot;#timeout&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</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>&lt;/div&gt;</p><p>&lt;hr&gt;
&lt;div id=&#39;which&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.which(name) -&gt; string
&lt;a href=&quot;#which&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</p><p>Checks if <code>name</code> is a valid command.
Will return the path of the binary, or a basename if it&#39;s a commander. </p><p class="font-bold text-xl" id="Parameters-string-**name**">Parameters
<code>string</code> **<code>name</code>** </p><p>&lt;/div&gt;</p><h2 class="font-bold text-3xl" id="Types-&lt;hr&gt;">Types
&lt;hr&gt;</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()--&gt;-string-Reads-a-liine-of-input-from-the-sink.">read() -&gt; string
Reads a liine of input from the sink.</p><p class="font-bold text-xl" id="readAll()--&gt;-string-Reads-all-input-from-the-sink.">readAll() -&gt; 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>&lt;hr&gt;
&lt;div id=&#39;run&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.run(cmd, streams)
&lt;a href=&quot;#run&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</p><p>Runs <code>cmd</code> in Hilbish&#39;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-&#39;fs&#39;-local-pr-pw-=-fs.pipe()-hilbish.run(&#39;ls--l&#39;-{- stdout-=-pw- stderr-=-pw-})-pw:close()-hilbish.run(&#39;wc--l&#39;-{- stdin-=-pr-})--&lt;/div&gt;">Example
<code>lua
-- This code is the same as `ls -l | wc -l`
local fs = require &#39;fs&#39;
local pr, pw = fs.pipe()
hilbish.run(&#39;ls -l&#39;, {
stdout = pw,
stderr = pw,
})
pw:close()
hilbish.run(&#39;wc -l&#39;, {
stdin = pr
})
</code>
&lt;/div&gt;</p><p>&lt;hr&gt;
&lt;div id=&#39;runnerMode&#39;&gt;
&lt;h4 class=&#39;heading&#39;&gt;
hilbish.runnerMode(mode)
&lt;a href=&quot;#runnerMode&quot; class=&#39;heading-link&#39;&gt;
&lt;i class=&quot;fas fa-paperclip&quot;&gt;&lt;/i&gt;
&lt;/a&gt;
&lt;/h4&gt;</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>&lt;/div&gt;</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>