From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26020 invoked by alias); 12 Sep 2016 22:25:56 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21882 Received: (qmail 22905 invoked from network); 12 Sep 2016 22:25:56 -0000 X-Qmail-Scanner-Diagnostics: from mail-lf0-f44.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.215.44):SA:0(0.0/5.0):. Processed in 0.432428 secs); 12 Sep 2016 22:25:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE, SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: jesper.nygards@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.215.44 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=oRlZOydkBN4zq/hgilUrYEy/PmzExSst32lrQAoJwtc=; b=CaVwf9ULkVZceUfdY1Plhze84cF4lEt6WsaS8hTkhfBu61mLMvQVFb82TPqqPx/Ru2 BwIBQswke96L2mhce8p9uE14VDf4PbY1/gFSFYo5J0XfjMwOeKpFXosfr3ueFVlPRynw FmpXNbS49TP5O3sRKAIs9HbEWHPMuqgmKOEpVKWrF+A5nXLERH4+piEIeBAWJRhGNUzl 7MtMQRMBsVzHXqWiJQ6d5pFKUu+VQZWHRrunCU36Sde0J+Vu/AcWoRfy67pVx6ewEKAh bELNXIUcFDalCnZBx+ntvmkmht+leiwKNzQjYuDZoHgbxc9nqLGkGIEdev2MOKW+/nzF FYkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=oRlZOydkBN4zq/hgilUrYEy/PmzExSst32lrQAoJwtc=; b=QTdmhSJR1ohTJ3uToaTiC+Iotm8hUVN8lrpjWALS2LtBUoRW9GLEZudygH75Fxbqce mZ9K1VWaAQ9Toimp6g0il4xvwxjFAOqON1N6DY7V37ZKJBSa9zw1aTl3BU6w5E40GAts qYBVTL44JrvCyIhBXV5kPIA3HyoCxp0vpveYfGcDGK0l5dp8BCjr661QFCCF9SMkRvzF efbU7+8ehai2YRtsYhJXSyJwq0Y8GmByjgx/XaumLs7Om2Tr3kbtPRv3M+B4v7QP4Oil 2zxS00KA3TR5AfGE9Ox84Ck8cQWWnRsopVBEgRSDFkrDW8fQkp+ZGww27Qdec7H9tbgP K5MQ== X-Gm-Message-State: AE9vXwOnK15+sjP5nZAibNdBaYPJsT5LsvBMEtygS/mpLS/K4FcJg4c6N0YNfzPj0i9oSpJDR71dMYahssd5Ag== X-Received: by 10.46.69.213 with SMTP id s204mr6394661lja.67.1473709389013; Mon, 12 Sep 2016 12:43:09 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <160912102321.ZM24807@torch.brasslantern.com> References: <160912102321.ZM24807@torch.brasslantern.com> From: =?UTF-8?Q?Jesper_Nyg=C3=A5rds?= Date: Mon, 12 Sep 2016 21:43:08 +0200 Message-ID: Subject: Re: Ignoring current directory with auto_cd To: Zsh Users Content-Type: multipart/alternative; boundary=001a114b0a54a2663d053c54b479 --001a114b0a54a2663d053c54b479 Content-Type: text/plain; charset=UTF-8 I am sorry, Bart. I realize now that my question was very badly worded. I'll see if I can explain what I meant with an example: Suppose I stand in a directory called "src". Since I have "zstyle ':completion:*:cd:*' ignore-parents parent pwd" set, if I type "cd ../s", I will not be offered "src" as a completion, since it gets excluded by the zstyle setting. However, if I only type "../s" (at the beginning of the command line), "src" will be one of the alternatives offered by completion. I realize this is because the completion system cannot know that it should exclude the current directory. So my question was: can I use something similar to the zstyle for cd completion to always exclude the current directory in such a situation? On Mon, Sep 12, 2016 at 7:23 PM, Bart Schaefer wrote: > On Sep 12, 2:32pm, Jesper Nygards wrote: > } > } Is there a way to make auto_cd also ignore the current directory, in the > } same way cd does with this zstyle set? I tried this without success: > } > } zstyle ':completion::complete:-command-::' ignore-parents parent pwd > > Styles of this sort only apply to completion (as might be obvious from > the word "completion" in the context) and only because there is a layer > of user-defined functions implementing most of the completion system. > There are no built-in shell operations that use zstyles values directly. > > This might mostly do what you want: > > autoload -Uz add-zsh-hook > > no-local-autocd() { > set -- "${(z)2}" > [[ $1 = */* ]] || unsetopt autocd > } > > reset-autocd { > setopt autocd > } > > add-zsh-hook preexec no-local-autocd > add-zsh-hook precmd reset-autocd > > I say "mostly" because if you do something like > > % echo foo ; /usr/bin > > the autocd to /usr/bin won't happen because "echo" caused the option to > be turned off. > > You can do a similar thing by overloading the accept-line ZLE widget, or > in more detail by using a DEBUG trap with the DEBUG_BEFORE_CMD option set, > but either of those has its own problems. > --001a114b0a54a2663d053c54b479--