RPROMPT is set to display svn info using
vcs_info. It reads
vcs_info is called using
precmd(). However, RPROMPT doesn't update when I change directories. It works only if I invoke the prompt again (either by source ~/.zshrc or prompt ) and doesn't change upon chdir, unless I invoke the prompt again. Is there any way to change this behaviour?
Using a single-quote to delay evaluation works for defining dynamic aliases as well. Here's an alias,
t, used to attach a new shell to an existing ssh agent process, which was started with an alias called
ssh-start that writes out shell code to a file in a homedir:
mymistress:~> which ssh-start ssh-start: aliased to eval `ssh-agent | tee ~/.ssh/ssh-agent.out` ; ssh-add ~/.ssh/id_rsa mymistress:~> grep "alias t" .zshrc alias t="eval `cat ~/.ssh/ssh-agent.out`" mymistress:~> which t t: aliased to eval SSH_AUTH_SOCK=/tmp/ssh-nZBZp29804/agent.29804; export SSH_AUTH_SOCK;\nSSH_AGENT_PID=29805; export SSH_AGENT_PID;\necho Agent pid 29805;`
That definition of
t is bad because it causes new information from a fresh run of
ssh-start to be ignored. Changing the alias definition of
t to be singly quoted in my .zshrc gives much better behavior:
mymistress:~> grep "alias t" .zshrc alias t='eval `cat ~/.ssh/ssh-agent.out`' mymistress:~> source ~/.zshrc mymistress:~> which t t: aliased to eval `cat ~/.ssh/ssh-agent.out`
Note the expansion of the definition of
t as provided by
which t, showing the effects of double quotes (immediate in-place expansion of commands or environment variables) vs. single quotes (delayed evaluation of commands and variables).