bakks / butterfish

A shell with AI superpowers
https://butterfi.sh
MIT License
294 stars 24 forks source link

Last line(s) of output disappear while in shell mode #8

Closed CoRoGi closed 1 year ago

CoRoGi commented 1 year ago

When running butterfish in shell mode, the responses I receive back will lose their last line or two once the command prompt is returned.

bakks commented 1 year ago

Hey @CoRoGi - can you tell me what terminal and shell you're using? And what your PS1 (terminal prompt) looks like? I haven't seen this bug so I suspect it's some setup I haven't tried.

CoRoGi commented 1 year ago

Hi, yes i'm using iTerm2 with zsh, with essentially an oh-my-zsh set up. Here's a picture:

Screenshot 2023-05-15 at 6 42 43 PM
bakks commented 1 year ago

Ahhh - so the issue is that the shell mode code is currently assuming a 1 line command prompt, that's why it's erasing the last few lines. Workaround is to change your PS1 to something that will only print a single line (e.g. export PS1='> ').

I want to support this though, I'm separately reworking how the prompt is handled so it will be a few days but should be able to make it work. Will respond back once it's working.

CoRoGi commented 1 year ago

Ah yes that certainly explains it, thank you! In case anyone else runs into this: I ended up updating my zshrc's ZSH_THEME variable to be a one line prompt (gallifrey in this case) instead of powerlevel10k and then sourced it + ran exec zsh to resolve this issue. Shell mode now displays its text just fine. Looking forward to the updates on supporting multiline command prompt!

bakks commented 1 year ago

👍 Going to leave this open for now until the multiline thing works

bakks commented 1 year ago

Ok @CoRoGi I did some more testing. My new conclusion - the issue here isn't the fact that the prompt was multiple lines, it was a zsh(?) feature called "Transient Prompt" that Powerlevel10k makes it easy to turn on. You likely flipped this on when configuring p10k.

The p10k behavior is that it uses transient prompting to print the ~...... line in your example, but then erases that line and later places it below so that your history looks a lot cleaner. Basically zsh/p10k is mucking with the terminal output in a way that's incompatible with Butterfish, and I don't see a good way to make it compatible.

So the upshot here is: you can still use p10k with Butterfish Shell, just don't turn on the Transient Prompt feature! I hope this helps, let me know if I've misinterpreted this.