Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Completion for cd



Hi,

one of the last upgrades of Zsh in Debian Sarge changed the way
directory names for cd are completed. With the current set of
functions, user's home directories are completed, which is a nuisance.

I think I have found the file to change:
/usr/share/zsh/4.1.1/functions/Completion/Zsh/_cd

Now, there are some problems:
1. I don't understand enough of the code to reliably remove user's
home directories from completion. I could fall back to an older
version of the file, but would loose completion of cdable vars.

The code in question is probably this part:
- - - Schnipp - - -
    # With cdablevars, we can complete foo as if ~foo/
    if [[ -o cdablevars && -n "$PREFIX" && "$PREFIX" != <-> ]]; then
      if [[ "$PREFIX" != */* ]]; then
        alt=( "$alt[@]" 'named-directories: : _tilde' )
      else
        local oipre="$IPREFIX" opre="$PREFIX" dirpre dir

        # Note we need a tilde because cdablevars also allows user home
        # directories, hence nonomatch (above) to suppress error messages.

        dirpre="${PREFIX%%/*}/"
        IPREFIX="$IPREFIX$dirpre"
        eval "dir=( ~$dirpre )"
        PREFIX="${PREFIX#*/}"

        [[ $#dir -eq 1 && "$dir[1]" != "~$dirpre" ]] &&
          _wanted named-directories expl 'directory after cdablevar' \
              _path_files -W dir -/ && ret=0

        PREFIX="$opre"
        IPREFIX="$oipre"
      fi
    fi
- - - Schnapp - - -

How to rip out home dir completion without affecting cdable vars?


2. I would like to do the change in a way that does not interfere with
future updates from Debian's package management system. Any ideas?


I'm not sure whether the change in behavior is the idea of the Zsh
team or of the Debian maintainer. I reported this as a bug to Debian,
but if someone here is closer to the source he might want to revert
this change in Zsh itself.


tia,

Thorsten
-- 
Don't let your sense of morals prevent you from doing what is right.
    - Isaac Asimov

Attachment: pgp5MznvFJEuI.pgp
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author