<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=#aliascmd-origclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Sets an alias of <code>cmd</code> to <code>orig</code></p><h4id=appendpathdirclass=heading>appendPath(dir)
<ahref=#appendpathdirclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Appends <code>dir</code> to $PATH</p><h4id=completescope-cbclass=heading>complete(scope, cb)
<ahref=#completescope-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><h4id=cwd---stringclass=heading>cwd() -> string
<ahref=#cwd---stringclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Returns the current directory of the shell</p><h4id=execcmdclass=heading>exec(cmd)
<ahref=#execcmdclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Replaces running hilbish with <code>cmd</code></p><h4id=gorofnclass=heading>goro(fn)
<ahref=#gorofnclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Puts <code>fn</code> in a goroutine</p><h4id=highlighterlineclass=heading>highlighter(line)
<ahref=#highlighterlineclass=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><h4id=hinterline-posclass=heading>hinter(line, pos)
<ahref=#hinterline-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><h4id=inputmodemodeclass=heading>inputMode(mode)
<ahref=#inputmodemodeclass=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><h4id=intervalcb-time---a-hrefhilbishdocsapihilbishhilbishtimerstimer-styletext-decoration-nonetimeraclass=heading>interval(cb, time) -> <ahref=/Hilbish/docs/api/hilbish/hilbish.timers/#timerstyle=text-decoration:none>Timer</a>
<ahref=#intervalcb-time---a-hrefhilbishdocsapihilbishhilbishtimerstimer-styletext-decoration-nonetimeraclass=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><h4id=multipromptstrclass=heading>multiprompt(str)
<ahref=#multipromptstrclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Changes the continued line prompt to <code>str</code></p><h4id=prependpathdirclass=heading>prependPath(dir)
<ahref=#prependpathdirclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Prepends <code>dir</code> to $PATH</p><h4id=promptstr-typclass=heading>prompt(str, typ)
<ahref=#promptstr-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><h4id=readprompt---input-stringclass=heading>read(prompt) -> input (string)
<ahref=#readprompt---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><h4id=runcmd-returnout---exitcode-number-stdout-string-stderr-stringclass=heading>run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string)
<ahref=#runcmd-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><h4id=runnermodemodeclass=heading>runnerMode(mode)
<ahref=#runnermodemodeclass=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><h4id=timeoutcb-time---a-hrefhilbishdocsapihilbishhilbishtimerstimer-styletext-decoration-nonetimeraclass=heading>timeout(cb, time) -> <ahref=/Hilbish/docs/api/hilbish/hilbish.timers/#timerstyle=text-decoration:none>Timer</a>
<ahref=#timeoutcb-time---a-hrefhilbishdocsapihilbishhilbishtimerstimer-styletext-decoration-nonetimeraclass=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><h4id=whichname---stringclass=heading>which(name) -> string
<ahref=#whichname---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><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 a liine of input from the sink.</p><h5id=readall---stringclass=heading>readAll() -> string
<ahref=#readall---stringclass=heading-link><iclass="fas fa-paperclip"></i></a></h5><p>Reads all 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)