Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Teardown for prompts
- X-seq: zsh-workers 30085
- From: Christian Höltje <docwhat@xxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Teardown for prompts
- Date: Thu, 5 Jan 2012 11:23:16 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:date:from:to:message-id:subject:x-mailer:mime-version :content-type; bh=zuzf1tZrJZThFf+eZEI6Tx20e/TmuCIfhWHPW6W1Ja0=; b=vuYRiYO5QrF5m/4MypXHsCSJw45kLouwXNqBYhYQ6osxUzmfC8IH/vexdbEmZ8D2N4 SoIG0j5koRVGiB99ow0B/nf3owqhfhZdZIgPcaDzdxhMPWDs8YD5jLj39+aFLLpV82X0 tvpXW6eZk/4fJOaGcUwN4RgqZEy3P57MuzhSk=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Sender: Christian Höltje <docwhat@xxxxxxxxx>
I have some suggestions for the promptinit stuff....
1) Remove other prompt related hooks. Currently, it removes preexec and precmd, but it doesn't remove chpwd, periodic, zshexit, nor zshaddhistory.
e.g.
for hook in preexec precmd chpwd periodic zshexit zshaddhistory; do
add-zsh-hook -D "${hook}" "prompt_*_${hook}"
done
Bonus points for getting the list of hooks from add-zsh-hook itself.
2) Add a teardown function. This could be used to unset things, etc. if the prompt changes. If prompt is switching from the prompt 'adam2', it would look for prompt_adam2_teardown and run it if it exists before switch to the new prompt.
3) On switching away from a prompt, look for any and all variables and functions with pattern "prompt_${current_prompt_name}_*" and unset/unfunction them.
I discovered this when I wrote a prompt that used the chpwd hook to try to minimize certain VCS checks (an optimization) and that function was still being called when I switched to a new prompt.
--
Christian Höltje
docwhat@xxxxxxxx
http://docwhat.org/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author