I tried:
vared -p '"$(print \"\e[1;31test\")" something' -c tmp
Output echo "$(print \"\e[1;31test\")" something
But I want to change color of test
word here. Howto achieve?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityI tried:
vared -p '"$(print \"\e[1;31test\")" something' -c tmp
Output echo "$(print \"\e[1;31test\")" something
But I want to change color of test
word here. Howto achieve?
The argument to -p
understands prompt expansion, so it's just:
var=; vared -p '%B%F{red}something%f: ' var
%B
: bold
(%b
to stop bold)%F{red}
: red foreground (%K
for bacKground).%f
: restore default foreground color.Doing:
vared -p $'\e[1;31msomething: ' var
which would be equivalent to vared -p "$(printf '\e[1;31msomething: ')"
(corrected from the version in your question) would be a bad idea as it would fool zle
's cursor positioning by letting it think that the prompt is 18 columns wide while in fact it's only 11 columns wide as \e[1;31m
is not visible.
Can achieve this by using double quotes after -p
and load colors
module of zsh.