OILS / doc / ref / chap-plugin.md View on Github | oilshell.org

96 lines, 56 significant
1---
2in_progress: yes
3body_css_class: width40 help-body
4default_highlighter: oils-sh
5preserve_anchor_case: yes
6---
7
8Plugins and Hooks
9===
10
11This chapter in the [Oils Reference](index.html) describes extension points for
12OSH and YSH
13
14<div id="toc">
15</div>
16
17## Signals
18
19TODO
20
21## Traps
22
23### DEBUG
24
25Runs code before "leaf" commands, like
26
27 echo hi
28 a=b
29 [[ x -eq y ]]
30 (( a = 42 ))
31
32But not before `{`:
33
34 { echo one; echo two; }
35
36---
37
38See the [Quirks doc](../quirks.html) for an interaction between the `DEBUG`
39trap, pipelines, and interactive shells.
40
41### ERR
42
43TODO
44
45### EXIT
46
47TODO
48
49### RETURN
50
51TODO
52
53## Words
54
55<!--
56<h3 id="PS1">PS1</h3>
57-->
58
59### PS1
60
61First line of a prompt.
62
63### PS2
64
65Second line of a prompt.
66
67### PS3
68
69For the 'select' builtin (unimplemented).
70
71### PS4
72
73For 'set -o xtrace'. The leading character is special.
74
75## Completion
76
77## Other Plugin
78
79## YSH
80
81### renderPrompt()
82
83Users may define this func to customize their prompt.
84
85The func should take the global `value.IO` instance, and return a prompt string
86(type `value.Str`).
87
88To construct the prompt, it can make calls like
89[`io->promptVal('$')`]($chap-type-method:promptVal).
90
91To render the prompt, YSH first checks if this function exists. Otherwise, it
92uses [`$PS1`]($chap-plugin:PS1) with a `ysh` prefix.
93
94<!-- note: doctools/cmark.py turns promptVal -> promptval -->
95
96