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

problem with function in prompt

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:


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() {

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?


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