zsh-workers
 help / color / mirror / code / Atom feed
From: Tomasz Moskal <boojum@stercus-accidit.com>
To: zsh-workers@zsh.org
Subject: Change terminal cursor shape from precmd()
Date: Wed, 23 Aug 2017 12:35:10 +0100	[thread overview]
Message-ID: <CACfAdfan-pGMWXAqL28Z0sVymODmSxjSXzyHnx3j2vBjFeTS8A@mail.gmail.com> (raw)

[-- 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.

                 reply	other threads:[~2017-08-23 11:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACfAdfan-pGMWXAqL28Z0sVymODmSxjSXzyHnx3j2vBjFeTS8A@mail.gmail.com \
    --to=boojum@stercus-accidit.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).