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 difference.

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

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" ?

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