Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 90907 - Zsh Gentoo prompt redefines precmd and preexec
Summary: Zsh Gentoo prompt redefines precmd and preexec
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Mamoru KOMACHI (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-29 15:13 UTC by Tom Martin (RETIRED)
Modified: 2005-05-22 09:27 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
prompt_gentoo_setup (prompt_gentoo_setup,1.19 KB, text/plain)
2005-05-04 11:14 UTC, Mamoru KOMACHI (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Martin (RETIRED) gentoo-dev 2005-04-29 15:13:56 UTC
From /usr/share/zsh/4.2.5/functions/Prompts/prompt_gentoo_setup:

  precmd  () { prompt_gentoo_precmd }
  preexec () { }

I don't know what exactly this is for, but it's *extremely frustrating*. If I do "prompt gentoo" before I redefine precmd and preexec in my zshrc then the prompt isn't set at all and I get the default prompt, and if I define it after then my precmd and preexec functions are overridden.

Thanks,
Tom
Comment 1 Mamoru KOMACHI (RETIRED) gentoo-dev 2005-05-03 00:05:02 UTC
Sorry but I don't understand what you are talking about.

If I do "prompt gentoo" before I redefine precmd and preexec,
the redefined precmd/preexec are used; and if I define precmd
and preexec before "prompt gentoo" then my precmd and preexec 
are overridden.
Comment 2 Tom Martin (RETIRED) gentoo-dev 2005-05-03 12:36:39 UTC
Hmm. Even if I trim down my zshrc to *just* the precmd/preexec and autoload -U promptinit; promptinit; prompt gentoo, then I get the same result: if I do prompt gentoo before I redefine precmd/preexec, I get the default prompt... hostname%.
Comment 3 Mamoru KOMACHI (RETIRED) gentoo-dev 2005-05-04 11:14:27 UTC
Created attachment 58047 [details]
prompt_gentoo_setup

Now I understand what you mean.

Does this fix your problem? You must call `prompt gentoo` before
defining your precmd/preexec, but this should keep gentoo prompt
when you have your own precmd/preexec.

If this is okay I'll commit it to CVS.
Comment 4 Tom Martin (RETIRED) gentoo-dev 2005-05-04 11:33:40 UTC
Wonderful, this fixes it. Thank you!

Tom
Comment 5 Mamoru KOMACHI (RETIRED) gentoo-dev 2005-05-05 08:14:27 UTC
ok, it's in CVS ;)
Comment 6 Tom Martin (RETIRED) gentoo-dev 2005-05-07 12:41:44 UTC
Hmm, okay, this fixes the issue mentioned in the bug initiallity, but it creates a new one. The prompt is the same for root user as it is for ordinary user, that is, green and blue rather than red and blue.
Comment 7 Mamoru KOMACHI (RETIRED) gentoo-dev 2005-05-22 07:07:43 UTC
It works well on my box (red and blue for root).
Could you show me the instruction to reproduce your problem?

mine:
usata@rico ~ % su -
rico root # zsh (<= red and blue, but bash)
\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]autoload -U promptinit
\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]promptinit
\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]prompt gentoo
rico ~ # (<= red and blue)
Comment 8 Tom Martin (RETIRED) gentoo-dev 2005-05-22 07:42:40 UTC
Yeah, I take exactly the same steps:

tmartin@pohl ~ % su
Password: 
pohl tmartin # zsh (bash; red and blue)
pohl# autoload -U promptinit (default zsh, white)
pohl# promptinit
pohl# prompt gentoo
root@pohl tmartin # (green and blue)

I have no .zshrc for root.
Comment 9 Mamoru KOMACHI (RETIRED) gentoo-dev 2005-05-22 08:02:39 UTC
You need to append '-' in order to prevent new user's shell
to inherit environment variables.

usata@rico ~ % su - (<- you see, '-' is important)

Now I understand what the problem is, and know how to
revert back, but I think the current (new) behaviour is the
right setting because if you do not append '-' almost all
variables are inherited, including $HOME and $USER, so
the prompt should also be inherited from previous user's.
What do you think?
Comment 10 Tom Martin (RETIRED) gentoo-dev 2005-05-22 09:21:13 UTC
I understand :)

I'm just going to have to tame my bad habits ;)

Ready to RESOLVE?

Thanks,
Tom
Comment 11 Mamoru KOMACHI (RETIRED) gentoo-dev 2005-05-22 09:27:25 UTC
Yup ;)