Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Dynamic colored command in zsh
- X-seq: zsh-users 15398
- From: Julien Nicoulaud <julien.nicoulaud@xxxxxxxxx>
- To: Michel <michel.barret@xxxxxxxxx>, zsh-users@xxxxxxx
- Subject: Re: Dynamic colored command in zsh
- Date: Mon, 13 Sep 2010 15:25:09 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=WMpMNnuDUf7SmAVS2AxuIbl93GZDmxHvT4VAwAT5/9Y=; b=wpWV/ZGy8MfPwCfmb4Qlp4IqEUA8GiypzpQGyBZ6O6lcwP7i6DqCMFqzA8O3gDggMT VUdBC0ry0DMjw4V2HJuBcckMEsa2Es1MjcohYe+5Rv88pG49lZCd2Dx9O66xFuFGtEJG mmqwTm8omvMp2ZASt32fZOMslNykJMmYoLQNA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=aZGJVqGBdVWJ4KMtbfwW+W6DpSn1/ohmmd9kSoZmDyzHBVCORDzG4zmwj6wYytPWWb a+Crn/vuSWn2a4+1SbYIwd99ZlHNKy6o7dJBr6dVhVkBAZp4UnGB13MXqR2DqlPReP3w YeuKnqrCkgpi05lsaYta1qF47iwWZryqb9UHo=
- In-reply-to: <20100913130345.GA9240@Lancelot>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <AANLkTinNJXay4pibEiQmKR4PSRcNiwCJ3w==Scc9rco0@xxxxxxxxxxxxxx> <20100913130345.GA9240@Lancelot>
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)____
> (__) )\
> ||--|| *
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author