Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Dynamic colored command in zsh
- X-seq: zsh-users 15399
- From: Roy Zuo <roylzuo@xxxxxxxxx>
- To: Julien Nicoulaud <julien.nicoulaud@xxxxxxxxx>
- Subject: Re: Dynamic colored command in zsh
- Date: Mon, 13 Sep 2010 21:44:08 +0800
- Cc: Michel <michel.barret@xxxxxxxxx>, zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mail-followup-to:references:mime-version:content-type :content-disposition:in-reply-to:x-pgp-key-id:user-agent; bh=Kkq5UKoCmBp3EGilx8Q3KNNj0YdwBzl4Khhoj8kKQ1g=; b=jWZYq49/DIuDXCnpscFTZ1X/GEkcvXxlJBRinyvxh5OuHgr9d/GyccQ4zeze+azED6 5acWJfvUqOIEQwl6znS7eqymruOt5BycW9m95+bsKlrLhFCmYyCCSlRe9Io88S+svONh gaNna0gGJ2PIlktdfT8fTunUzxvrIkiQejszY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :x-pgp-key-id:user-agent; b=rofgzYHB8ZiJ9uOHTzOFfooBdmUTWwLvRy79q83S5ZNpN7n49hAkcb6eEXY8dAeaPp Or5kOAfA4ce6IrQnCF3VEAkJpyCambM/g+Rw1H3knO8dmVxDu5HM7FZAQnKfd6LxaKpq 6VgnMx9dN8bqtWuNI+t0C/5+dAvPiX0LVVvhc=
- In-reply-to: <AANLkTikq=h-awW+-HAB8-QWdg0dWTuY+uydMu-Ezmt-0@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: Julien Nicoulaud <julien.nicoulaud@xxxxxxxxx>, Michel <michel.barret@xxxxxxxxx>, zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <AANLkTinNJXay4pibEiQmKR4PSRcNiwCJ3w==Scc9rco0@xxxxxxxxxxxxxx> <20100913130345.GA9240@Lancelot> <AANLkTikq=h-awW+-HAB8-QWdg0dWTuY+uydMu-Ezmt-0@xxxxxxxxxxxxxx>
Hi Julien,
Which version of zsh are you using? If you are using 4.2.x, i.e. the default
version under Centos 5, you would have this problem because operator "=~" is not
defined. Even if you are able to get around this, you still cannot use my script
because "region_highlight" is not defined in 4.2.x too.
Roy
On Mon, Sep 13, 2010 at 03:25:09PM +0200, Julien Nicoulaud wrote:
> Wow, that would be great !
>
> Roy, can you give us the options you use ? The "=~" equalities throw errors
> for me.
>
> 2010/9/13 Roy Zuo <roylzuo@xxxxxxxxx>
>
> > Yes, I tried today and made some progress. I can make the color for the
> > command
> > to change whenever I type a new character or delete one. However my ZLE
> > skill is
> > quite limited and someone else might be able to make this also work when
> > TAB is
> > pressed.
> >
> > recolor-cmd() {
> > args=(${(z)BUFFER})
> > cmd=$args[1]
> > res=$(builtin type $cmd 2>/dev/null)
> > [ -z $res ] && return
> > if [ $res =~ 'reserved word' ]; then
> > color="magenta"
> > elif [ $res =~ 'an alias' ]; then
> >
> > color="cyan"
> > elif [ $res =~ 'shell builtin' ]; then
> > color="yellow"
> > elif [ $res =~ 'shell function' ]; then
> > color='green'
> > elif [ $res =~ "$cmd is" ]; then
> > color="blue"
> > else
> > color="red"
> > fi
> > region_highlight=("0 ${#cmd} fg=${color},bold")
> > }
> >
> > check-cmd-self-insert() { zle .self-insert && recolor-cmd }
> > check-cmd-backward-delete-char() { zle .backward-delete-char &&
> > recolor-cmd }
> >
> > zle -N self-insert check-cmd-self-insert
> > zle -N backward-delete-char check-cmd-backward-delete-char
> >
> > Regards,
> >
> > Roy
> >
> > On Sun, Sep 12, 2010 at 12:04:08PM +0200, Michel wrote:
> > > Hello,
> > >
> > > Is it possible to have the dynamic colored command in zsh as in fish ?
> > >
> > > By example : if I type "grep", for each caracter before the "p" the
> > > word is colored in red but when I type the last caractere the word is
> > > colored in green. The coloring should be appled on parameters, string
> > > (between 2 " or '), the color should be different if the word is
> > > alias, function or command.
> > >
> > > Thanks for your answer
> > >
> > > Nice day
> > > _____________________
> > > Michel BARRET
> > >
> >
> > --
> > _________________________
> > < Murphy was an optimist. >
> > -------------------------
> > \ ,__,
> > \ (oo)____
> > (__) )\
> > ||--|| *
> >
--
______________________________________________________________________
/ MSDOS didn't get as bad as it is overnight -- it took over ten years \
| of careful development. |
| |
\ -- dmeggins@xxxxxxxxxxxxxxx /
----------------------------------------------------------------------
\ ,__,
\ (oo)____
(__) )\
||--|| *
Messages sorted by:
Reverse Date,
Date,
Thread,
Author