-
-
Notifications
You must be signed in to change notification settings - Fork 171
How Interactive Shells Work
andychu edited this page Mar 11, 2020
·
19 revisions
- Back to Interactive Shell (a page of ideas)
Let's figure out how interactive shells work! bash, zsh, fish, and Oil are significantly different. The goal is to figure out:
- What interactive features Oil should have. (Right now, it's mostly bash-like)
- What hooks/APIs it should have so that others can implement nice interactive experiences (like zsh plugins and
ble.shon top of bash)
Please add links or hand-written descriptions in the sections below, or talk to us on #oil-discuss at https://oilshell.zulipchat.com/ (log in with Github)
And if there are too many details, feel free to create new pages and add links to them.
- The prompt.
- In POSIX shell this is
$PS1and$PS2. - bash has extensions.
- Does a shell have to know how wide the prompt is to draw correctly? (note: this depends on unicode chars in the propmt)
- In POSIX shell this is
- Shell Autocompletion -- when you hit TAB, what happens
- Autosuggestions -- does it display suggestions on the prompt line automatically? That is, there is no prompting.
- Spell correct? zsh has this I think.
- History. What format is the history stored in?
- in bash it's a text file, which gives it an odd "two level store" behavior: see issue 324
note: feel free to split this into more wiki pages
- It uses GNU Readline. bash and readline are maintained together.
- It provides
$LINES,$COLUMNS, andtrap SIGWINCHhooks -
$PS1and$PS2for prompt - many options and vars for history, like
$HISTFILE, etc. - it has a
command_not_foundhook
- TODO: What are the common plugins and what do they expect from the shell?
Features
- autosuggestions
TODO
- is there a "main loop" ?
- what does it expect from bash?
-
$LINES,$COLUMNS - it needs to trap
SIGWINCH(todo: test this signal in Oil)
-
- how does it execute commands?
Oil is mostly bash-like now. I added a zsh-like completion interface that doesn't scroll every time you hit TAB, but it has some bugs, like #257.
-
Search for
\x1bto see all the escape codes Oil uses: https://github.com/oilshell/oil/blob/master/core/comp_ui.py