Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--index switch #48

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ EXAMPLES
z -r foo cd to highest ranked dir matching foo
z -t foo cd to most recently accessed dir matching foo
z -l foo list all dirs matching foo (by frecency)
z --index index all subdirectories of the current dir


NOTES
Expand Down
3 changes: 3 additions & 0 deletions z.1
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ directory that matches ALL of the regexes given on the command line.
\fB\-r\fR match by rank only
.br
\fB\-t\fR match by recent access only
.br
\fB\--index\fR Index all subdirectories of the current dir
.br

.SH EXAMPLES
\fBz foo\fR cd to most frecent dir matching foo
Expand Down
5 changes: 5 additions & 0 deletions z.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ _z() {

# bail out if we don't own ~/.z (we're another user but our ENV is still set)
[ -f "$datafile" -a ! -O "$datafile" ] && return
# Index subdirectories
if [ "$1" = "--index"]; then
find `pwd` -type d | while read line
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is probably a more effective way to go about this if you know the exact implementation of the --add-algorithm, I just had no time to look into that. As always, feel free to tweak it with your knowledge ;-)

do _z --add $line
done

# add entries
if [ "$1" = "--add" ]; then
Expand Down