Offensive Thinking

Internet Thoughtcrime

ZLE Woes

Posted: 2009-04-23

Since a few weeks, I’ve been converted to using the Zsh instead of the ever-present bash. And I’m quite content with it, the expressiveness and possibilities of the Zsh are really awesome. There’s only one thing that bothers me at the moment, and it seems to be a bug in at least the version I work with (4.3.9).

I’m using the following function (adapted from zshwiki) to show me on the right-hand side of my prompt if I’m in insert or normal mode, since I’ve set my shell to work in vi-mode. It will also show if I’m currently in a shell spawned from within vim (with :sh), as I quite frequently jump from vim to a shell and back when working:

function zle-line-init zle-keymap-select {
  if [ $VIMRUNTIME ]; then RPROMPT="[v|"; else RPROMPT="["; fi
  zle reset-prompt
zle -N zle-line-init
zle -N zle-keymap-select
zle -N edit-command-line

The problem is that zle reset-prompt should reset the shell not only when the mode changes (zle-keymap-select), but also when the shell is initialised (zle-line-init). The latter does not work properly. So I have to hit enter once when opening a new shell, or it will behave weirdly. Apparently, I’m not the only one with this problem.

I hope this gets fixed soon. Besides this annoyance, the Zsh is quite fun to work with.