From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29322 invoked by alias); 24 Mar 2011 20:47:14 -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: 15889 Received: (qmail 5598 invoked from network); 24 Mar 2011 20:47:03 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at agrussell.com designates 204.251.33.236 as permitted sender) Message-Id: From: Stephen Prater To: zsh-users@zsh.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: problem with function in prompt Date: Thu, 24 Mar 2011 15:23:48 -0500 X-Mailer: Apple Mail (2.936) I have the following function in a sourced file.. function free_mem() { FM=$(ruby -e ' x = `vm_stat`.each_line.to_a[0..4].join.scan(/([0-9]*?) \./).flatten.map { |i| (i.to_i * 4096) / 1000000 }; y = `sysctl hw.memsize`.split(/:\s/).last.to_i / 1000000; puts "%F{82}#{x[0]}%f/%F{yellow}#{x[2]}%f/%F{69}#{y}%f";') echo $FM } and then in my prompt i have this: $(free_mem) The problem is that it never re-executes the function in the prompt ---- setopt prompt_subst PROMPT_INFO="$(draw f21 ul hbar) $(host_name)- %L $(draw f21 ll hbar) $(dir_name) $(free_mem)" DEF_PROMPT="${(e)${PROMPT_INFO}} %F{cyan} [ %f" INS_MODE_PROMPT="${(e)${PROMPT_INFO}} %F{red} [ %f" The value that appears in the prompt is always the same as the one when the shell was initially executed. I tried placing it in a variable within precmd and then using that variable in the prompt like this: precmd() { FREE_MEM=$(free_mem) } PROMPT="$FREE_MEM" but that didn't work either If I call free_mem directly from the prompt (or echo FREE_MEM) it outputs the correct string... so what am I missing? stephen