<ahref=#introductionclass=heading-link><iclass="fas fa-paperclip"></i></a></h3><p>The Hilbish module includes the core API, containing
interfaces and functions which directly relate to shell functionality.</p><h3id=interface-fieldsclass=heading>Interface fields
<ahref=#interface-fieldsclass=heading-link><iclass="fas fa-paperclip"></i></a></h3><ul><li><code>ver</code>: The version of Hilbish</li><li><code>goVersion</code>: The version of Go that Hilbish was compiled with</li><li><code>user</code>: Username of the user</li><li><code>host</code>: Hostname of the machine</li><li><code>dataDir</code>: Directory for Hilbish data files, including the docs and default modules</li><li><code>interactive</code>: Is Hilbish in an interactive shell?</li><li><code>login</code>: Is Hilbish the login shell?</li><li><code>vimMode</code>: Current Vim input mode of Hilbish (will be nil if not in Vim input mode)</li><li><code>exitCode</code>: xit code of the last executed command</li></ul><h3id=functionsclass=heading>Functions
<ahref=#hilbishaliascmd-origclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Sets an alias of <code>cmd</code> to <code>orig</code></p><h5id=parametersclass=heading>Parameters
<ahref=#parametersclass=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishappendpathdirclass=heading>hilbish.appendPath(dir)
<ahref=#hilbishappendpathdirclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Appends <code>dir</code> to $PATH</p><h5id=parameters-1class=heading>Parameters
<ahref=#parameters-1class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishcompletescope-cbclass=heading>hilbish.complete(scope, cb)
<ahref=#hilbishcompletescope-cbclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Registers a completion handler for <code>scope</code>.
A <code>scope</code> is currently only expected to be <code>command.<cmd></code>,
replacing <cmd>with the name of the command (for example <code>command.git</code>).
<code>cb</code> must be a function that returns a table of “completion groups.”
Check <code>doc completions</code> for more information.</p><h5id=parameters-2class=heading>Parameters
<ahref=#parameters-2class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishcwd---stringclass=heading>hilbish.cwd() -> string
<ahref=#hilbishcwd---stringclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Returns the current directory of the shell</p><h5id=parameters-3class=heading>Parameters
<ahref=#parameters-3class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishexeccmdclass=heading>hilbish.exec(cmd)
<ahref=#hilbishexeccmdclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Replaces running hilbish with <code>cmd</code></p><h5id=parameters-4class=heading>Parameters
<ahref=#parameters-4class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishgorofnclass=heading>hilbish.goro(fn)
<ahref=#hilbishgorofnclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Puts <code>fn</code> in a goroutine</p><h5id=parameters-5class=heading>Parameters
<ahref=#parameters-5class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishhighlighterlineclass=heading>hilbish.highlighter(line)
<ahref=#hilbishhighlighterlineclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Line highlighter handler. This is mainly for syntax highlighting, but in
reality could set the input of the prompt to <em>display</em> 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.
</code></pre><p>This code will highlight all double quoted strings in green.</p><h5id=parameters-6class=heading>Parameters
<ahref=#parameters-6class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishhinterline-posclass=heading>hilbish.hinter(line, pos)
<ahref=#hilbishhinterline-posclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><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><h5id=parameters-7class=heading>Parameters
<ahref=#parameters-7class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishinputmodemodeclass=heading>hilbish.inputMode(mode)
<ahref=#hilbishinputmodemodeclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Sets the input mode for Hilbish’s line reader. Accepts either emacs or vim</p><h5id=parameters-8class=heading>Parameters
<ahref=#parameters-8class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishintervalcb-time---a-hrefhilbishdocsapihilbishhilbishtimerstimer-styletext-decoration-none-idloltimeraclass=heading>hilbish.interval(cb, time) -> <ahref=/Hilbish/docs/api/hilbish/hilbish.timers/#timerstyle=text-decoration:noneid=lol>Timer</a>
<ahref=#hilbishintervalcb-time---a-hrefhilbishdocsapihilbishhilbishtimerstimer-styletext-decoration-none-idloltimeraclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Runs the <code>cb</code> function every <code>time</code> milliseconds.
This creates a timer that starts immediately.</p><h5id=parameters-9class=heading>Parameters
<ahref=#parameters-9class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishmultipromptstrclass=heading>hilbish.multiprompt(str)
<ahref=#hilbishmultipromptstrclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Changes the continued line prompt to <code>str</code></p><h5id=parameters-10class=heading>Parameters
<ahref=#parameters-10class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishprependpathdirclass=heading>hilbish.prependPath(dir)
<ahref=#hilbishprependpathdirclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Prepends <code>dir</code> to $PATH</p><h5id=parameters-11class=heading>Parameters
<ahref=#parameters-11class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishpromptstr-typclass=heading>hilbish.prompt(str, typ)
<ahref=#hilbishpromptstr-typclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Changes the shell prompt to <code>str</code>
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><h5id=parameters-12class=heading>Parameters
<ahref=#parameters-12class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishreadprompt---input-stringclass=heading>hilbish.read(prompt) -> input (string)
<ahref=#hilbishreadprompt---input-stringclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><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 (which shouldn’t happen)</p><h5id=parameters-13class=heading>Parameters
<ahref=#parameters-13class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishruncmd-returnout---exitcode-number-stdout-string-stderr-stringclass=heading>hilbish.run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string)
<ahref=#hilbishruncmd-returnout---exitcode-number-stdout-string-stderr-stringclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Runs <code>cmd</code> in Hilbish’s sh interpreter.
If returnOut is true, the outputs of <code>cmd</code> will be returned as the 2nd and
3rd values instead of being outputted to the terminal.</p><h5id=parameters-14class=heading>Parameters
<ahref=#parameters-14class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishrunnermodemodeclass=heading>hilbish.runnerMode(mode)
<ahref=#hilbishrunnermodemodeclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>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.</p><h5id=parameters-15class=heading>Parameters
<ahref=#parameters-15class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishtimeoutcb-time---a-hrefhilbishdocsapihilbishhilbishtimerstimer-styletext-decoration-none-idloltimeraclass=heading>hilbish.timeout(cb, time) -> <ahref=/Hilbish/docs/api/hilbish/hilbish.timers/#timerstyle=text-decoration:noneid=lol>Timer</a>
<ahref=#hilbishtimeoutcb-time---a-hrefhilbishdocsapihilbishhilbishtimerstimer-styletext-decoration-none-idloltimeraclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Runs the <code>cb</code> function after <code>time</code> in milliseconds.
This creates a timer that starts immediately.</p><h5id=parameters-16class=heading>Parameters
<ahref=#parameters-16class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h4id=hilbishwhichname---stringclass=heading>hilbish.which(name) -> string
<ahref=#hilbishwhichname---stringclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><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><h5id=parameters-17class=heading>Parameters
<ahref=#parameters-17class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>This function has no parameters.</p><h3id=typesclass=heading>Types
<ahref=#autoflushautoclass=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>Sets/toggles the option of automatically flushing output.
A call with no argument will toggle the value.</p><h5id=flushclass=heading>flush()
<ahref=#flushclass=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>Flush writes all buffered input to the sink.</p><h5id=read---stringclass=heading>read() -> string
<ahref=#read---stringclass=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>Reads input from the sink.</p><h5id=writestrclass=heading>write(str)
<ahref=#writestrclass=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>Writes data to a sink.</p><h5id=writelnstrclass=heading>writeln(str)