Skip to content

How Interactive Shells Work

andychu edited this page Mar 11, 2020 · 19 revisions

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.sh on 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)

Parts of the Interactive Shell

  • The prompt.
    • In POSIX shell this is $PS1 and $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)
  • 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

Research

note: feel free to split this into more wiki pages

How Bash Works

  • It uses GNU Readline. bash and readline are maintained together.

How Zsh Works

  • TODO: What are the common plugins and what do they expect from the shell?

How Fish Works

Features

  • autosuggestions

How ble.sh Works

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?

How Oil Works

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.

Clone this wiki locally