Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Outputting colored zsh prompts from an external script
- X-seq: zsh-users 17741
- From: TJ Luoma <luomat@xxxxxxxxx>
- To: seanh <snhmnd@xxxxxxxxx>
- Subject: Re: Outputting colored zsh prompts from an external script
- Date: Thu, 28 Mar 2013 17:14:20 -0400
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=c3yztKGc3I/ACuHqYEuD/qXgptLs99xVWNpkiuwQndM=; b=gyZJn1gQjMCn6qfKCL9tatKxWRdHp5SStv1lDU/dfP5RcnIT1QCoquSUiaD3slp1Cx BVC1D8heMdmrTsCKWAH9KQDgqB28MLlRdUmPjQ7RL1vwOfPAUkFAaw6mFRR5sDkzrhvg 6VS0qmvX1w6Ry3pRjpNGbvmbL2w05kNn6qPwp45lhdBOUSgttRb80sEuQehnWkO5q2cC 5TJ5423VkMBupNP1OnpAwYzyYzAosDwQHgNrSYDIM9ihOslgvriMt8N0XqpN03oKVrD2 BCKthmhADbn0C0ZA6CH94OBskfg6xzl9GSecRcV0B7Cu/4G3x+G3Kro4F0pkH2xqAjhh yM6w==
- In-reply-to: <20130328202651.GA24482@kaeru>
- 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: <20130324192345.GA20437@kaeru> <871ub431wq.fsf@gmail.com> <CAMvu5b+RCigGy-rjtyQB_H_vYF1MPC4PjEW0NBgFYrJEYnViZw@mail.gmail.com> <130325082938.ZM24580@torch.brasslantern.com> <20130325194000.GA27762@kaeru> <20130328202651.GA24482@kaeru>
On Thu, Mar 28, 2013 at 4:26 PM, seanh <snhmnd@xxxxxxxxx> wrote:
> Anyone know how I can make zsh call this script for PROMPT and RPROMPT,
> but fall back on a simple pure-zsh prompt if trying to call the script
> exits with non-zero? (Yes, my zsh-scripting skills really are that
> limited.)
>
> It does what I wanted from my prompt, with maybe a couple of minor
> wrinkles that could be smoothed out. If I can get custom format options
> working, it might be useful to others who want to design their own
> prompts. I'm thinking it'd work something like this, for example to get
> a zsh prompt with current working dir, virtualenv, git branch and last
> exit status, you would put something like this in your zshrc:
>
> PROMPT='$(zshprompt.py --format "{cwd:green} {venv:blue} {git:yellow} {les:red,bold}> ")'
>
> and zshprompt.py would do all the work to handle current working
> directory truncation and git branch, virtualenv and non-zero exit status
> detection, handle colours and bold etc and transform that (hopefully
> simple) string specification into the much more complex string that zsh
> needs for the prompt.
As someone who has never been able to figure out colors for zsh
prompts, I love this idea.
I don't know if there's a 'better' way to do this, but you could do it this way
FOO="$(a || b)"
if the exit code for 'a' != 0 then b will run.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author