From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29366 invoked by alias); 29 Mar 2013 15:07:54 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17742 Received: (qmail 20843 invoked from network); 29 Mar 2013 15:07:42 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <130329080726.ZM30118@torch.brasslantern.com> Date: Fri, 29 Mar 2013 08:07:26 -0700 In-reply-to: <20130328202651.GA24482@kaeru> Comments: In reply to seanh "Re: Outputting colored zsh prompts from an external script" (Mar 28, 9:26pm) References: <20130324192345.GA20437@kaeru> <871ub431wq.fsf@gmail.com> <130325082938.ZM24580@torch.brasslantern.com> <20130325194000.GA27762@kaeru> <20130328202651.GA24482@kaeru> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: seanh , zsh-users@zsh.org Subject: Re: Outputting colored zsh prompts from an external script MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Mar 28, 9:26pm, seanh 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.) If exiting nonzero implies no output, you can do something like this: PROMPT="${$(zshprompt.py left ...):-$PROMPT}" where :- means that if the left side is empty, use the right side, so the above effectively leaves the prompt unchanged if the script does not output anything on stdout. If you really want to test "exit nonzero" then you have to use two steps: pyprompt="$(zshprompt.py left ...)" && PROMPT="$pyprompt" or if pyprompt="$(zshprompt.py left ...)"; then PROMPT="$pyprompt"; fi or [[ -x =zshprompt.py ]] && PROMPT="$(zshprompt.py left ...)" etc.