From 7dbe2bd602f25f04da58b260d6940d6a13ca9722 Mon Sep 17 00:00:00 2001 From: rupa Date: Wed, 26 Mar 2014 13:02:21 -0400 Subject: [PATCH] handle EXCLUDE_DIRS in main script --- z.sh | 8 ++++++++ z_prompt_command.c | 9 --------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/z.sh b/z.sh index fd81b59..4fa6c90 100644 --- a/z.sh +++ b/z.sh @@ -33,10 +33,15 @@ _z() { # bail if we don't own ~/.z (we're another user but our ENV is still set) [ -f "$datafile" -a ! -O "$datafile" ] && return + local exclude; + # tab completion if [ "$1" = "--complete" ]; then while read line; do [ -d "${line%%\|*}" ] && echo $line + for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do + [ "${line%%\|*}" = "$exclude" ] && continue + done done < "$datafile" | awk -v q="$2" -F"|" ' BEGIN { if( q == tolower(q) ) imatch = 1 @@ -78,6 +83,9 @@ _z() { local cd cd="$(while read line; do [ -d "${line%%\|*}" ] && echo $line + for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do + [ "${line%%\|*}" = "$exclude" ] && continue + done done < "$datafile" | awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" ' function frecent(rank, time) { # relate frequency and time diff --git a/z_prompt_command.c b/z_prompt_command.c index 8b32359..18cadb8 100644 --- a/z_prompt_command.c +++ b/z_prompt_command.c @@ -35,15 +35,6 @@ int main(int argc, char **argv) { /* Don't track $HOME */ if (strcmp(argv[1], getenv("HOME")) == 0) return EXIT_SUCCESS; - /* - TODO - # don't track excluded dirs - local exclude - for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do - [ "$*" = "$exclude" ] && return - done - */ - _Z_DATA = getenv("_Z_DATA"); if( _Z_DATA == NULL ) { sprintf(datafile, "%s/.z", getenv("HOME"));