Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 213627 - app-shells/zsh - expand the default config
Summary: app-shells/zsh - expand the default config
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Piotr Karbowski (RETIRED)
URL:
Whiteboard:
Keywords:
: 554648 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-03-16 20:55 UTC by Michael Hammer (RETIRED)
Modified: 2022-11-26 21:45 UTC (History)
6 users (show)

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


Attachments
default /etc/zsh/zshrc for a better default config (zshrc,214 bytes, text/plain)
2008-03-16 20:56 UTC, Michael Hammer (RETIRED)
Details
A better gentoo prompt (prompt_gentoo_setup,3.21 KB, text/plain)
2008-04-05 14:40 UTC, Leonardo Valeri Manera
Details
A *term title function for gentoo zsh (xterm_title_setup,529 bytes, text/plain)
2008-04-05 14:42 UTC, Leonardo Valeri Manera
Details
A better^2 gentoo prompt (prompt_gentoo_setup,3.23 KB, text/plain)
2008-04-05 18:59 UTC, Leonardo Valeri Manera
Details
A better^3 gentoo prompt (prompt_gentoo_setup,3.31 KB, text/plain)
2008-04-15 08:24 UTC, Leonardo Valeri Manera
Details
/etc/zsh/zshrc (zshrc,525 bytes, text/plain)
2015-07-13 17:46 UTC, Alon Bar-Lev (RETIRED)
Details
~/.zprofile (.zprofile,52 bytes, text/plain)
2015-07-13 17:48 UTC, Alon Bar-Lev (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Hammer (RETIRED) gentoo-dev 2008-03-16 20:55:27 UTC
I've just started to use zsh as standard shell for my users. I found it really sad that the default configuration of the zsh is nearly unusable. I would suggest to add a /etc/zshrc which at least synchronize the behavior of our default zsh and bash.

I would appreciate to discuss the issue. I would say the bad default config of the zsh is a nameable reason for the reservation of unexperienced users to use the zsh.

g, mueli

Reproducible: Always

Steps to Reproduce:
Comment 1 Michael Hammer (RETIRED) gentoo-dev 2008-03-16 20:56:51 UTC
Created attachment 146343 [details]
default /etc/zsh/zshrc for a better default config
Comment 2 Dawid Węgliński (RETIRED) gentoo-dev 2008-03-16 21:08:07 UTC
Sigh, your attachment does provide nothing but prompt, so it is still almost 'unusable'. And if i were you i wouldn't give zsh as a default shell for unexperienced users, honestly.
Comment 3 Michael Hammer (RETIRED) gentoo-dev 2008-03-17 07:34:56 UTC
Then let us expand the zshrc so that it is "usable" - I really see no reason why gentoo configures the bash and the zsh comes _without_ completion, a colored prompt and colored ls output. IMHO it's not wright if you say my suggestions provide "nothing" - it makes the default zsh in gentoo "gentoo-look-alike".

@unexperienced users: Why shouldn't they start with zsh? I can't see a disadvantage of the zsh for even unexperienced shell users. zsh is perhaps even better for them (IMHO) - _but_ a lot depends on the configuration. Two points are for my users essential to except new things: They have to look like the old (that's why "prompt gentoo" is not nothing for me) and they expect the same core features (therefore a compinit is the minimum).

I would like to see much more features and default options in the /etc/zshrc - but I wanted to start on a minimum. But if we find a majority - why not expand the /etc/zshrc to something nearly everybody has set? That doesn't mean that we brake per user defaults in ~/.zshrc, so in my opinion it's save to do so.

g, mueli
Comment 4 Michael Hammer (RETIRED) gentoo-dev 2008-03-17 09:34:22 UTC
one further comment:

Why do we set the environment (PATH, EDITOR) in /etc/zprofile? This file is only called if the shell opened is a login shell. Shouldn't this be transfered into /etc/zshenv?
Comment 5 Torsten Veller (RETIRED) gentoo-dev 2008-03-17 10:18:01 UTC
I am not sure how far we want to go with /improving/ the default configuration files.
We can also improve <http://www.gentoo.org/doc/en/zsh.xml>.

Should we try to get an overlay to play with it? Jokey, is it possible?

In <https://bugs.gentoo.org/show_bug.cgi?id=19924#c18> usata commented on the gentoo prompt and vanilla use-flag. I'd like to add an useflag for no (or minimal) changes too.


(In reply to comment #4)
> Why do we set the environment (PATH, EDITOR) in /etc/zprofile? This file is
> only called if the shell opened is a login shell. Shouldn't this be transfered
> into /etc/zshenv?

No, see <https://bugs.gentoo.org/show_bug.cgi?id=19924#c13> and the following comments.
Comment 6 Michael Hammer (RETIRED) gentoo-dev 2008-03-17 10:56:50 UTC
(In reply to comment #5)
> I am not sure how far we want to go with /improving/ the default configuration
> files.
> We can also improve <http://www.gentoo.org/doc/en/zsh.xml>.

My effort would really go in the direction of a "ready to use" config and not a documentation of how I can make the default config look like a gentoo shell.

> In <https://bugs.gentoo.org/show_bug.cgi?id=19924#c18> usata commented on the
> gentoo prompt and vanilla use-flag. I'd like to add an useflag for no (or
> minimal) changes too.

Haven't seen that - I find it a really nice idea. Everybody can decide if he likes a vanilla zsh or not. Why not introduce a "gentoo-shell" USE or something like that to indicate a base configuration which looks like a gentoo shell? Can I assist you in anyway to accomplish that?

> > Why do we set the environment (PATH, EDITOR) in /etc/zprofile? This file is
> > only called if the shell opened is a login shell. Shouldn't this be 
> > transfered into /etc/zshenv?
> 
> No, see <https://bugs.gentoo.org/show_bug.cgi?id=19924#c13> and the following
> comments.

ACK - just learned about zsh ;)
Comment 7 Leonardo Valeri Manera 2008-04-05 14:40:00 UTC
Created attachment 148735 [details]
A better gentoo prompt

This is the result of my work in making a better gentoo zsh prompt.

By default it behaves exactly like the one currently provided - same colours and same path clipping.

However, it is customisable via zstyles:

In the :gentoo:prompt context, the following styles are available:

'user-color', 'root-color', 'prompt-color' set what you think they do.

'path' sets the type of path clipping to be used. It can have any of these 4 values:
 - 'subdir' is the stock zsh "maximum number of subdirectories" type clipping. The amount of subdirs to be displayed is set with the 'subdir' style. This is the default and the number also defaults to 3, like the gentoo prompt we currently have in the package.
 - 'full' shows the full path with no clipping.
 - 'fixed' uses string-lenght to decide how many directories to clip, and the lenght is set with the 'lenght' style and defaults to 20.
 - 'ratio' uses a $COLUMNS/ratio value for maximum lenght, so its like the above but scaled to terminal width. The ratio can be set with the 'ratio' style and defaults to 6.

The values are picked up during runtime, so just setting the style in a terminal will change the way the prompt is displayed in that terminal, and setting it in your .zshrc and sourcing that will update the looks also without needing to reinitialize the prompt via prompt_init.
Comment 8 Leonardo Valeri Manera 2008-04-05 14:42:56 UTC
Created attachment 148737 [details]
A *term title function for gentoo zsh

This is its companion, an xterm title function that works by default like the gentoo bash xterm title, but with the value of the xterm title settable via the ':gentoo:xterm' title style.

It uses the precmd_functions array so it does not interfere with prompts which use precmd.
Comment 9 Leonardo Valeri Manera 2008-04-05 18:59:02 UTC
Created attachment 148770 [details]
A better^2 gentoo prompt

Updated a little - fixed a bug with subdir mode, added a style to specify the string to prepend to cut paths - defaults to '..' - made the length-based cutter loop readable.
Comment 10 Leonardo Valeri Manera 2008-04-15 08:24:31 UTC
Created attachment 149777 [details]
A better^3 gentoo prompt

Small update, now the length-based cutter works correctly when dealing with very long directory names.
Comment 11 Alexander Huemer 2008-07-13 22:38:00 UTC
how should the *term title function be used?
i pasted the assignment into my .zshrc and .zprofile, but i still get a plain "xterm" on new xterms. same result with gnome terminal.
i also suggest to fix the bindkey thing. with bash the "home", "end" and "del" keys work out-of-the-box, even in gnu screen. that's not the case with zsh.
i have some of the values for xterm and screen on a different hdd, not accessible right now. i can post them later.
and currently there seems to be some problem with DIR_COLORS. on my newly installed machine i do not get the different filetypes colors with zsh and cannot find out why.
http://forums.gentoo.org/viewtopic-p-5150628.html
Comment 12 Alon Bar-Lev (RETIRED) gentoo-dev 2015-07-13 17:33:32 UTC
*** Bug 554648 has been marked as a duplicate of this bug. ***
Comment 13 Alon Bar-Lev (RETIRED) gentoo-dev 2015-07-13 17:46:44 UTC
Created attachment 406686 [details]
/etc/zsh/zshrc

1. set dir colors
2. set gentoo prompt
Comment 14 Alon Bar-Lev (RETIRED) gentoo-dev 2015-07-13 17:48:33 UTC
Created attachment 406688 [details]
~/.zprofile

Not sure how we can automate this, but for the record, ~/.zprofile should source the ~/.profile
Comment 15 Alon Bar-Lev (RETIRED) gentoo-dev 2015-07-13 17:50:04 UTC
"A better^3 gentoo prompt" looks good, anything that will make the full directory printed is better than last component, simpler approach available in bug#554648.
Comment 16 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2015-07-17 08:22:37 UTC
Why is this bug rotting for so long despite having such valuable contributions?

(In reply to Alon Bar-Lev from comment #14)
> Created attachment 406688 [details]
> ~/.zprofile
> 
> Not sure how we can automate this, but for the record, ~/.zprofile should
> source the ~/.profile

How about adding it to /etc/skel? So at least new created users havbe it immediately.
Comment 17 Khayyam 2016-04-01 13:37:48 UTC
(In reply to Lars Wendler (Polynomial-C) from comment #16)
> > Not sure how we can automate this, but for the record, ~/.zprofile should
> > source the ~/.profile
> 
> How about adding it to /etc/skel? So at least new created users havbe it
> immediately.

Please don't do this (source ~/.profile via ~/.zprofile), its not needed because /etc/zsh/zprofile is sourcing /etc/profile.env (and so the 'basic' env is provided) and if a user needs to overide this then that is entirely up to them. The assumption that this needs to be provided is somewhat bogus, because by default there is no .profile (in /etc/skel) and if the user, by chance, has one then, again, leave it to them to decide on if that file is sourced or not. Nothing really needs to be done in that regard, because /etc/zsh/* is looked to first, and ~/.z{,profile,sh{rc,env}} should be considered as entirely at the disgression of the user.

As for the above /etc/zsh/zshrc (provided by Alon), I have the following comments to make:

1). I don't think autoload is required, terminfo is automatically loaded because zle, etc, need to query term (so that could be dropped).

2). I'd frame the 'test' like so:

if (($terminfo[colors] > 8)) && (($+commands[dircolors])) ; then
    if [[ -f ~/.dir_colors ]]; then
        eval "$(dircolors -b ~/.dir_colors)"
    elif [[ -f /etc/DIR_COLORS ]]; then
        eval "$(dircolors -b /etc/DIR_COLORS)"
    fi
fi

... so using zsh provided arrays to determine term capabilities and presence of 'dircolors'.

3). The ls and grep aliases, and zstyle, don't need to be inside the test condition. You get 'list-colors' on any colour capable term (ie, TERM=linux) so the presence of dircolors is not required, and having '--color=auto' is fine with 8 colours.