zsh-workers
 help / color / mirror / code / Atom feed
* Re: Outputting colored zsh prompts from an external script
       [not found]   ` <CAMvu5b+RCigGy-rjtyQB_H_vYF1MPC4PjEW0NBgFYrJEYnViZw__868.462134576653$1364217014$gmane$org@mail.gmail.com>
@ 2013-03-25 15:42     ` Christian Neukirchen
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Neukirchen @ 2013-03-25 15:42 UTC (permalink / raw)
  To: zsh-workers

seanh <snhmnd@gmail.com> writes:

>> I ported this to zsh for fun:
>>
>> fishpwd() {
>>   local maxlen=${1:-20} pwd
>>   local -a segs
>>
>>   segs=("${(s:/:)${(D)PWD}}")
>>
>>   for i in {1..$(($#segs-1))}; do
>>     pwd=${(j:/:)segs}
>>     (( $#pwd <= maxlen )) && break
>>
>>     segs[$i]=${segs[$i][1]}
>>   done
>>
>>   print $pwd
>> }
>
> Yeah. I know that everything I want to do with zshprompt.py can be
> done in pure zsh and I'm sure it can even be done elegantly in zsh.
> The prompt I'm using right now, until I get zshprompt.py colors
> working, is a pure zsh prompt that I implemented that has most of
> zshprompt.py's features.
>
> But the problem is that your zsh code is completely meaningless to me
> because I don't know zsh. If I learned zsh well enough to do the
> prompt I want, the in six months' time when I  want to change my
> prompt or fix a bug I'll have forgotten all about it again because I
> won't have used zsh scripting since. I write Python every day, so
> being able to define zsh prompts by calling external programs (python
> or otherwise) seems really empowering for letting more people hack
> their zsh prompts.
>
> So far this color issue is the only thing getting in my way...

Then try generating "%F{...}" codes like in my other mail.  It works here.

-- 
Christian Neukirchen  <chneukirchen@gmail.com>  http://chneukirchen.org


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Outputting colored zsh prompts from an external script
       [not found] <20130324192345.GA20437__22562.4022576541$1364153239$gmane$org@kaeru>
@ 2013-03-24 21:30 ` Christian Neukirchen
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Neukirchen @ 2013-03-24 21:30 UTC (permalink / raw)
  To: zsh-workers

seanh <snhmnd@gmail.com> writes:

> I also tried getting zshprompt.py to print out zsh color codes like
> %{$fg[red]%}FOO%{$reset_color%}, but zsh doesn't seem to interpret these
> when they're printed by zshprompt.py, it just prints them out into the
> prompts literally. I tried various zsh options with this, such as
> setopt promptpercent and setopt promptsubst, and tried various other ways of
> calling the Python script, such as within double-quotes or back-ticks
> instead of single-quotes, or without any quotes at all. Nothing worked.

This works here (note how it gets executed every time):

setopt promptsubst
PROMPT+='$(date +"%%F{red}%H:%M:%S%%f") '

Alternatively, you could try setting the prompt in a precmd().

But I expect terrible performance from running a python command before
every prompt.  It does not seem very hard to port that python code there
to plain zsh.

Have fun,
-- 
Christian Neukirchen  <chneukirchen@gmail.com>  http://chneukirchen.org


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-25 15:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20130324192345.GA20437@kaeru>
     [not found] ` <871ub431wq.fsf@gmail.com>
     [not found]   ` <CAMvu5b+RCigGy-rjtyQB_H_vYF1MPC4PjEW0NBgFYrJEYnViZw__868.462134576653$1364217014$gmane$org@mail.gmail.com>
2013-03-25 15:42     ` Outputting colored zsh prompts from an external script Christian Neukirchen
     [not found] <20130324192345.GA20437__22562.4022576541$1364153239$gmane$org@kaeru>
2013-03-24 21:30 ` Christian Neukirchen

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).