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