Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Change terminal cursor shape from precmd()



Ahoy there!

I want to change the cursor shape based on user id (root/not-root) from
within the prompt. I thought that precmd() will be the place to do it but
my attempts so far... well, failed. Here's the whole prompt, including not
working precmd() part:

emulate -RL zsh
setopt prompt_subst

prompt_k2_setup() {

   function precmd() {
     if [[ ! $(id -u) -eq 0 ]]; then
       echo -ne "\033]12;#fffeb3\007\e[3 q]"
     else
       echo -ne "\033]12;#ae0001\007\e[1 q]"
     fi
 }

  function zle-keymap-select {
    psvar[1]="${${KEYMAP/vicmd/:}/(main|viins)/}"
    zle reset-prompt
    psvar[1]=""
}

  zle -N zle-keymap-select

  PS1=' %B%(?|%166F|%124F)%1(V|%1v|%(#|#|>))%(?|%166f|%124f)%b '
}

prompt_k2_setup "$@"


Could someone point out what am I doing wrong here?


T.


Messages sorted by: Reverse Date, Date, Thread, Author