Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Ignoring current directory with auto_cd
- X-seq: zsh-users 21877
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Ignoring current directory with auto_cd
- Date: Mon, 12 Sep 2016 10:23:21 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=AkiRug9CDyB82U0dXNWg5CvcTX2YAL+jQ8glLXvU7xY=; b=RxAwGC8J9anADvXa6LqnM1ymSF0mux3MjBJElY2f+9N9D9LZWgxfeS4Y+H52715keP JT2z6660o8toOQoJvze/BX9whl4JuSJljkRjgYrbJZcK263OzqMGtvWjB/DiJfONz+qd kAV6kkbM58CMB0J+V7ty/h+VODmEFLgmIRQvDWGzr2Ikj8MHDmijjH9xHAddalVMWqZG 7OJTwnQgmi/kemxvoZfPeNUFHN3mdE+G0mfte8r2+lfhulUgbHJEyJMbf5A3QNsjCM98 POjItxtedso6ok8zf57pvt9ZxGana4ZgTei9Fz/OF15FYr79e6YxgEWzjTBs+LuBPHyK NfQw==
- In-reply-to: <CABZhJg9se+WgA+tdvxKTd+UeHFLWibQpnqmOr=AAHBr4mz_DSg@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CABZhJg9se+WgA+tdvxKTd+UeHFLWibQpnqmOr=AAHBr4mz_DSg@mail.gmail.com>
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author