Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Change terminal cursor shape from precmd()
- X-seq: zsh-workers 41586
- From: Tomasz Moskal <boojum@xxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Change terminal cursor shape from precmd()
- Date: Wed, 23 Aug 2017 12:35:10 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stercus-accidit.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=QnEPPLKtdqdYxjWBOt+FpUUVAF6mR0iso0NIAvUc0CE=; b=h2sSFkE5rlfONB57ak0CD6zDn3Ul5I7BiIGWQfrCfWrpm/jrUTEgF9Kw0gLGActom+ r//sHn2/PmNBrC2plIgNPiQNvADO26mTLb5ZTxkn+gKKw8XZb+HKkqbwWUy/dx4tT1S7 B0RzuGA3du1ZGkoQMknZbT3LHphsZWsGXiafQ=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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