#794967 zsh: please enhance /etc/zshrc

Package:
zsh
Source:
zsh
Description:
shell with lots of features
Submitter:
Carsten Hey
Date:
2015-08-10 21:09:04 UTC
Severity:
wishlist
#794967#5
Date:
2015-08-08 20:25:27 UTC
From:
To:
Please enhance /etc/zshrc:

 * Please add some additional keybindings, at least for the emacs keymap:

   - bind PageUp "${terminfo[kpp]}" to history-search-backward

   - bind PageDown "${terminfo[knp]}" to history-search-forward

     The bash like history-search-end magic would be an alternative for
     PageUp and PageDown, but history-search-backward does not require
     running zle -N ...

   - bind BackTabKey "${terminfo[kcbt]}" to reverse-menu-complete

     In terminfo(5), the capname cbt is described as "back tab (P)"
     and kcbt is described as "back-tab key", therefore the suggested
     'BackTabKey' instead of 'BackTab' - even though grml confuses
     people that know terminfo(5) by using 'BackTab' as name.

   - Maybe F1 could invoke run-help?  But then the output of run-help
     w/o arguments should be more useful for new users.

   - Red Hat maps or mapped space to magic-space, I think Debian should
     _not_ do this, but initially I thought that this would be a good
     idea.

 * $key should be unset unless there is a reason for not doing so.

 * (( ${+aliases[run-help]} )) requires the zsh/parameter module.  If,
   in rare cases, possibly involving zsh-static, there is a chance that
   this module is not loaded successfully, you should consider doing
   this instead to remove the alias w/o error message:

     alias run-help=
     unalias run-help

#794967#10
Date:
2015-08-08 21:46:34 UTC
From:
To:
Carsten Hey wrote:
[...]

I firmly believe, that a vendor's *global* setup file should be as
minimal as possible, which is why I really don't want to add anything
that's more than making the zsh defaults behave more robustly across
multiple terminals or deal with stuff specific to Debian.

This is stuff for the recommended setup file.

By that logic, kpp would need to be mapped to "PreviousPageKey". I think
the current naming is fine.

Again, this fits into the recommended setup file

The reason I left it set, is because its layout matches the $key
dictionary, that zsh's "zkbd" function produces and can be used as a
drop-in replacement. I still think that's a reasonable idea, even though
it slightly violates the "A vendor's global setup needs to be minimal"
rule.

That's a good point. I think we can do it like this:

    unhash -a -m 'run-help' || true

#794967#13
Date:
2015-08-08 23:35:24 UTC
From:
To:
* Frank Terbeck [2015-08-08 23:46 +0200]:

It looks like you changed your opinion since you wrote
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=622933#10

No, there is no such name collusion with kpp.  What would be the name of
cbt if kcbt is BackTab?  Actually, the name does not matter ;)

The difference is that Red Hat destroys or destroyed existing mappings
with binding Space to magic-space.  Binding BackTab, which is unbound by
default, does not annoy or harm anybody.  The same applies to PageUp and
PageDown.  Nothing you wrote changed my opinion that BackTab, PageUp and
PageDown should by bound to something useful by default.

If you can imagine a real world use case and nobody complains, it's fine :)
would make this intension more clear.

If there is a reason to write something in a way that is less
straight-forward to read, one could add a comment that explains the
code.

debootstrap --foreign ... enters a chroot without /dev/null, there might
be other rare but valid cases where /dev/null is not available.
Normally this is not a problem (everybody does this, POSIX allows it,
...), but I'd like to avoid such things in default shell rc files and
especially in global shell rc files to avoid issues in rare corner
cases.


Carsten

#794967#16
Date:
2015-08-09 00:00:37 UTC
From:
To:
* Frank Terbeck [2015-08-08 23:46 +0200]:

Btw., we agree on this part, "Space -> magic-space" and "F1 -> run-help"
are possible candidates for a recommended setup file, but not for
a global zshrc (I should have waited a few minutes after having the idea
to map F1, instead of immediately sending the bug report).


Carsten

#794967#21
Date:
2015-08-09 08:19:56 UTC
From:
To:
Hi!

Carsten Hey wrote:
[...]


Heh. I honestly don't even remember sending those mails. I do remember
the issue (ie. the fact that Ubuntu does compinit in the global zshrc),
but I thought my reaction had matched my reaction right now.


For the record, let it be known that the statement from my previous mail
in *this* thread is indeed my actual position in the matter. And it has
been for a while. I'm sure there is evidence of that in threads of other
bug reports that would show that.

Today I wouldn't take that code snippet from my own mail to enter our
setup. It's the wrong thing to do. I think they still do that in Ubuntu,
which is another reason why "setopt no_global_rcs" is part of my
personal zsh setup in my "~/.zshenv" file.


Regards, Frank

#794967#24
Date:
2015-08-10 21:07:51 UTC
From:
To:
Hi,

running zsh -u leads to this warning message:

    /etc/zsh/zshrc:14: DEBIAN_PREVENT_KEYBOARD_CHANGES: parameter not set

(My answer to "Don't do that" is "If this is not allowed, zsh should not
 accept -u for interactive shells".)

The fix is to replace lines 14 and 15 with:

    if [[ -z "${DEBIAN_PREVENT_KEYBOARD_CHANGES-}" ]] &&
       [[ "${TERM-}" != 'emacs' ]]

* Frank Terbeck [2015-08-08 23:46 +0200]:

We agreed on using unalias -m, not unhash -m.  Whether the argument
should be quoted is in this case just a matter style, personal
preferences and syntax highlighting.

If it is sourced with errexit set, or if someone removes the final line
(which might not be that unlikely) and sources this file, appending '||
:' or '|| true' (the former is a POSIX special builtin, but zsh seems to
ignore this difference) actually makes a difference, and for the errexit
case it would not be sufficient to make the final command return 0.

During shell startup errexit is ignored in /etc/zsh/zshrc.  I don't
know whether the exit status of /etc/zsh/zshrc could matter.
I also don't know why anybody would source /etc/zsh/zshenv, but
appending '|| :' just in case someone does seems to be sensible.

Could anybody with commit access please replace the old unalias line
with one of lines below?

    unalias -m 'run-help' || :
    unalias -m 'run-help' || true
    unalias -m run-help || :
    unalias -m run-help || true

This bug actually is about the bindkey stuff we don't agree on, and
I don't consider this robustness fixes to sufficient to close the bug
(YMMV and you are free close this bug anyway).  Maybe it could be tagged
as wontfix to document that we don't agree currently.


Carsten