[solved] Any multiline zsh compatible shells? [zsh config]
Some time ago I found xonsh which is a python-based shell. It had really good multiline support, and I am searching for a shell with sameish multiline support as xonsh. Fish shell also has good multiline support, it is around the same level, but it is not posix compatible. I want a shell that has that kind of level of multiline, but zsh (bash is also fine) compatible.
Does anyone know of one?
edit: based on the replies, I get this is unclear. My problem with zsh is that if i press enter and it starts a new line, I can’t get back to the prevous line, because a new prompt is started. In fish this is possible, all lines are one prompt. But, fish is not posix compatible. So, I guess I want a posix-compatible shell with fish-like lines (multiple line) editing. I wanted zsh support to keep using my custom oh-my-zsh prompt, but remaking it for a new shell is not a big problem. Sorry for being unclear.
edit 2: solution is here! Thanks to @andy I started thinking and made the following: When on the first line, enter accepts and alt-enter inserts a newline. When not on the first line, enter inserts a newline and alt-enter accepts. Here is the code to put in your .zshrc
:
<span style="color:#323232;"># MULTILINE!!!
</span><span style="color:#323232;">bindkey '^[e' push-line-or-edit
</span><span style="color:#323232;">
</span><span style="color:#323232;"># enter accepts when only one line found, else creates newline
</span><span style="color:#323232;">function _zle_ml_enter {
</span><span style="color:#323232;"> if ! [[ $BUFFER == *$'n'* ]]; then
</span><span style="color:#323232;"> zle accept-line
</span><span style="color:#323232;"> else
</span><span style="color:#323232;"> zle self-insert-unmeta
</span><span style="color:#323232;"> fi
</span><span style="color:#323232;">}
</span><span style="color:#323232;">zle -N _zle_ml_enter
</span><span style="color:#323232;">bindkey '^M' _zle_ml_enter
</span><span style="color:#323232;">
</span><span style="color:#323232;"># alt-enter accepts when more than one line found, else creates newline
</span><span style="color:#323232;">function _zle_ml_meta_enter {
</span><span style="color:#323232;"> if [[ $BUFFER == *$'n'* ]]; then
</span><span style="color:#323232;"> zle accept-line
</span><span style="color:#323232;"> else
</span><span style="color:#323232;"> zle self-insert-unmeta
</span><span style="color:#323232;"> fi
</span><span style="color:#323232;">}
</span><span style="color:#323232;">zle -N _zle_ml_meta_enter
</span><span style="color:#323232;">bindkey '^[^M' _zle_ml_meta_enter
</span><span style="color:#323232;">
</span>
edit:
changed if [[ “$BUFFERLINES” -le 1 ]]; then
to if ! [[ $BUFFER == *$‘n’* ]]; then
and if [[ “$BUFFERLINES” -gt 1 ]]; then
to if [[ $BUFFER == *$‘n’* ]]; then
for improving detection. Also added alt-e shortcut because I had that configured myself but forgot to add here.
Add comment