diff --git a/z.1 b/z.1 index c1e41ad..2e5c225 100644 --- a/z.1 +++ b/z.1 @@ -55,6 +55,8 @@ Optionally: Set \fB$_Z_NO_RESOLVE_SYMLINKS\fR to prevent symlink resolution. .br Set \fB$_Z_NO_PROMPT_COMMAND\fR to handle \fBPROMPT_COMMAND/precmd\fR yourself. +.br + Set \fB$_Z_EXCLUDE_DIRS\fR to an array of directories to exclude. .br (These settings should go in .bashrc/.zshrc before the lines added above.) .br @@ -120,6 +122,10 @@ variable to maintain its database. In zsh, \fBz\fR appends a function .P The environment variable \fB$_Z_NO_PROMPT_COMMAND\fR can be set if you want to handle \fBPROMPT_COMMAND\fR or \fBprecmd\fR yourself. +.P +The environment variable \fB$_Z_EXCLUDE_DIRS\fR can be set to an array of +directories to exclude from tracking. \fB$HOME\fR is always excluded. +Directories must be full paths without trailing slashes. .SH FILES Data is stored in \fB$HOME/.z\fR. This can be overridden by setting the diff --git a/z.sh b/z.sh index db5dab3..25e2d2f 100755 --- a/z.sh +++ b/z.sh @@ -12,6 +12,7 @@ # set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z). # set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution. # set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself. +# set $_Z_EXCLUDE_DIRS to an array of directories to exclude. # # USE: # * z foo # cd to most frecent dir matching foo @@ -34,6 +35,12 @@ _z() { # $HOME isn't worth matching [ "$*" = "$HOME" ] && return + # don't track excluded dirs + local exclude + for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do + [ "$*" == "$exclude" ] && return + done + # maintain the file local tempfile tempfile="$(mktemp $datafile.XXXXXX)" || return