tldr is this tweet below.
like this. https://t.co/PAnzshoafV pic.twitter.com/hnxcHDAAIP
— Tomonori Takanawa (@_takanawa_) February 11, 2021
First of all, I knew the difference of single quotations and double quotations on shell scripting language (especially bash and zsh), the former wouldn’t expand the variables yet the latter would, but I’m not sure function with them work on PROMPT.
So I will write the point what happen when you use double quotes on you PROMPT just in case such as the tweet would be deleted.
2021-02-12-do-not-use-double-quotations-on-your-prompt
First, I encountered the bug which the zsh prompt won’t display the git status correctly, for example, the case I’m not on git project when zsh launched is zsh don’t display git status (branch name and so on) whether I cd to-git-project-directory
, but other case which I’m on git project when zsh launched, it goes on displaying the branch name even if cd other-directory-not-git-project
.
This bug cause is double quotations I put them on my zsh PROMPT. When you use double quotations on zsh PROMPT, zsh expand its content only at zsh launched, so this will lead to a bug relevant displaying git status.
So you should use single quotes on PROMPT. Sadly I struggled this problem for a few hours. Thank you.
The diff commit is c9499d09 which is my github repository I store my dotfiles.