Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.

Plugins and Hooks

This chapter in the Oils Reference describes extension points for OSH and YSH

Table of Contents
Signals
Traps
DEBUG
ERR
EXIT
RETURN
Words
PS1
PS2
PS3
PS4
Completion
Other Plugin
YSH
renderPrompt()

Signals

TODO

Traps

DEBUG

Runs code before "leaf" commands, like

echo hi
a=b
[[ x -eq y ]]
(( a = 42 ))

But not before {:

{ echo one; echo two; }

See the Quirks doc for an interaction between the DEBUG trap, pipelines, and interactive shells.

ERR

TODO

EXIT

TODO

RETURN

TODO

Words

PS1

First line of a prompt.

PS2

Second line of a prompt.

PS3

For the 'select' builtin (unimplemented).

PS4

For 'set -o xtrace'. The leading character is special.

Completion

Other Plugin

YSH

renderPrompt()

Users may define this func to customize their prompt.

The func should take the global value.IO instance, and return a prompt string (type value.Str).

To construct the prompt, it can make calls like io->promptVal('$').

To render the prompt, YSH first checks if this function exists. Otherwise, it uses $PS1 with a ysh prefix.


Generated on Wed, 13 Mar 2024 14:59:38 -0400