You are not logged in.
Hello, I have written this for the .zshrc to change the cursor color to red when in cmd mode on the zsh command line.
zle-keymap-select () {
if [ $KEYMAP = vicmd ]; then
echo -ne "\033]12;Red\007"
else
echo -ne "\033]12;Grey\007"
fi
}
zle -N zle-keymap-select
zle-line-init () {
zle -K viins
echo -ne "\033]12;Grey\007"
}
zle -N zle-line-init
bindkey -v
It works well in urxvt however my tty does not know what to do with the escape codes so It just prints them to the command line. Is there any command for changing the cursor color that is for urxvt only? I think this would fix the problem.
Thanks,
Andreas
Offline
I tried this but it's not working unfortunately but it might help you if you are better than me at zsh coding
zle-keymap-select () {
if [ "$TERM" = "rxvt-256color" ]; then
if [ $KEYMAP = vicmd ]; then
echo -ne "\033]12;Red\007"
else
echo -ne "\033]12;Grey\007"
fi
fi
}
zle -N zle-keymap-select
zle-line-init () {
zle -K viins
}
zle -N zle-line-init
Offline
This is simply awesome. Just need to figure out how to get it to use the green I've defined in Xdefaults...
I'd wager that more than just rxvt can parse the escape codes properly, so I would personally use:
if [ "$TERM" != "linux" ]; then ....
Offline
Cool! The extra $TERM conditional works. Thank you.
With xterm the color changing does not work as well, the cursor color only changes back to insert-mode-color once text is being typed.
This is working for me. I may simplify it later.
zle-keymap-select () {
if [ $TERM = "rxvt-256color" ]; then
if [ $KEYMAP = vicmd ]; then
echo -ne "\033]12;Red\007"
else
echo -ne "\033]12;Grey\007"
fi
fi
}
zle -N zle-keymap-select
zle-line-init () {
zle -K viins
if [ $TERM = "rxvt-256color" ]; then
echo -ne "\033]12;Grey\007"
fi
}
zle -N zle-line-init
bindkey -v
There are many colorname choices in /usr/share/X11/rgb,txt
You can also add colors. Or just use rgb values directly, apparently. More about the color stuff here.
EDIT: You can just use the hex as you defined it in your .Xdefaults:
echo -ne "\033]12;#83C048\007"
Last edited by AndreasBWagner (2010-05-01 02:48:28)
Offline
Oh very cool. Sure enough, using #xxxxxx works for specifying colors by hex value.
And unfortunately, you're also right about the limited terminal support. Looks like screen can't change the cursor color via escape codes even if you try to fool it into thinking its rxvt. Ah well.
Edit: looks like im too slow on the submit button.
Last edited by falconindy (2010-05-01 02:53:42)
Offline
Strange, discovered that this addition causes me to segfault. The most easily repeatable is to do something like this:
$ echo "foo bar
> ^C
That is, start a quoted string, and Control-C out of after getting a newline at a PS2.
Here's the section of .zshrc that's causing the issue:
bindkey -v
zle-keymap-select () {
if [ "$TERM" = "rxvt-256color" ]; then
if [ $KEYMAP = vicmd ]; then
echo -ne "\033]12;#ff6565\007"
else
echo -ne "\033]12;#93d44f\007"
fi
fi
}; zle -N zle-keymap-select
zle-line-init () {
zle -K viins
echo -ne "\033]12;#93d44f\007"
}; zle -N zle-line-init
Can anyone else here replicate this?
Offline
@falcon works for me.
@OP nice thing, thanks
Offline