richsoni
richsoni

Reputation: 4278

zsh prompt function not running

I am trying to learn about custom prompts in zsh, and I am having the following issue:

With this code:

print_dir(){
  echo $PWD 
}

export PROMPT=$'%{%F{134}%}$(print_dir)%{%f%}
%{%F{231}%}❯%{%f%} '

I get this output instead of the result of the function:

$(project_pwd)

I know this function is not needed here, but I want to expand it as I learn.

Why is the function not executing?

Upvotes: 6

Views: 2504

Answers (1)

qqx
qqx

Reputation: 19495

You need to do setopt prompt_subst. This is documented in the zshoptions man page, which viewable on the zsh website.

Upvotes: 9

Related Questions