Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Outputting colored zsh prompts from an external script



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.



Messages sorted by: Reverse Date, Date, Thread, Author