<- Back to garden entrance

There's a lot of cool things i feel like terminals and/or shells could do.

I think i've read about nushell before, but never bothered to try it out. I rediscovered it today and there's a lot of good stuff there. I think i also saw warp terminal a while back, and thought "why is every other terminal window just a text grid, we can do so much more".

So here's some stuff i've been thinking about:

shower thoughts time

okay, so what should actually be the responsibility of the shell, and what should be the responsibility of the terminal? shells are usually responsible for making the prompts, including styling, content, functionality, etc. I believe this is not the case in warp. there's an option to either use the shell's builtin prompt, or it lets you make your own which is rendered by warp itself.

what about warp's "blocks"? in warp's case, it's the terminal. well, basically any feature warp has is done by the terminal, because warp is the terminal, and you just plug your existing shell in there. but in this utopian future we're imagining, whose responsibility is it to make these blocks? you could argue it's the shell, because that's what controls when commands are run, so it can say to start a new block when a command finishes, for example. on the other hand, the blocks are a part of the terminal's ui. i could maybe see the shell's job becoming very complicated if it has to manage all this UI state, and communicate with the terminal about what to do with it. a lot easier for the shell to say "command's done" and "command's about to be executed", which is how warp works, as far as i've understood. though, i guess programs like tmux already manage all their own ui state, so maybe it's not so farfetched to ask a shell to do the same. i think i'm personally leaning in the direction of it being the shell's responsibility to render these blocks, and you'd configure your shell's options if you wanted the blocks to spawn bottom-to-top instead of top-to-bottom, for example.

so, the terminal basically becomes this blank canvas for the shell to do its thing with (like it always has been), except the shell has a lot more flexibility in what it can ask the terminal to render, instead of just plain text.

next question, what should that be? you'd want to support a couple different things. blocks, prompts, data structure visualizations (like nushell's tables, for example). the terminal would send events to the shell if you click on a prompt segment, allowing the shell to maybe render a popup-menu where you can do something useful, like change git branch. you'd also want the flexibility to make a little search box in the popup. should this be a primitive too? if not, you don't want it to be too complex either i think, because then the shell has to send over a lot of data, and the terminal has to interpret it and render it per the shell's instructions. you probably want to be somewhere inbetween "i'm running a command now, you go figure what you wanna do with that" (warp's current model) and "draw a quad here, then render this text here, then draw another quad, then …". i guess current normal terminals are quite close to the latter, where shells just say "render this text", sprinkled with some ansi escape codes for colors and cursor management. or maybe this is not a spectrum, but two distinct possibilities, and the actual spectrum is how "advanced" the render interface is, where text is the least advanced and raw render calls are the most advanced. and you wanna find a sweet spot inbetween there.

get your pitchforks ready

...what if it was javascript. "hey artemis, what the fuck", you might say. and i hear you, and i agree. but it's also something that like, exists. it's probably not the answer in the long run, but i feel like it could be a good starting point, letting you (me) focus on prototyping a neat shell. here's the pitch:

the shell would probably start off with appending a prompt element to the empty document, and then a box for text to go in. when it receives a keypress, it adds that character to the end of that box. when it receives an enter press, it makes a new scrollable element which it dumps stdout and stderr of the process into, as well as sending further keypresses onwards to the running process's stdin. when the process exits, it makes a new prompt element and box, and prepares to get more user input.

cons?:

pros: i can prototype this without inventing a whole protocol for shell<->terminal communication