Oils Reference — Chapter Plugins and Hooks

This chapter describes extension points for OSH and YSH.

(in progress)

In This Chapter

Signals

SIGTERM

SIGTERM is the default signal sent by kill. It asks a process to terminate.

You can register a SIGTERM handler with the trap builtin.

SIGINT

SIGINT is usually generated by Ctrl-C. It interrupts what the shell is doing and returns to the prompt.

You can register a SIGINT handler with the trap builtin.

SIGQUIT

SIGQUIT is usually generated by Ctrl-.

SIGTTIN

Used by the job control implementation.

SIGTTOU

Used by the job control implementation.

SIGWINCH

Oils receives this signal when the terminal window size changes.

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

complete

The complete builtin calls back into the shell evaluator to create candidate strings for autocompletion:

Other Plugin

PROMPT_COMMAND

A command that's executed before each prompt.

This feature is taken from bash.

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 Sun, 25 Aug 2024 12:30:01 -0400