zsh-workers
 help / color / mirror / code / Atom feed
* Change terminal cursor shape from precmd()
@ 2017-08-23 11:35 Tomasz Moskal
  0 siblings, 0 replies; only message in thread
From: Tomasz Moskal @ 2017-08-23 11:35 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-08-23 11:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-23 11:35 Change terminal cursor shape from precmd() Tomasz Moskal

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).