Allow changing the max score for aging
user can set _Z_MAX_SCORE (probably not the greatest name). Closes #231
This commit is contained in:
1 parent
e77e938493
commit
dcd5541e7d
3 files changed
+9
-2
No files matched your search
@@ -59,6 +59,8 @@ NOTES
|
|||||||
Optionally:
|
Optionally:
|
||||||
Set $_Z_CMD to change the command name (default z).
|
Set $_Z_CMD to change the command name (default z).
|
||||||
Set $_Z_DATA to change the datafile (default $HOME/.z).
|
Set $_Z_DATA to change the datafile (default $HOME/.z).
|
||||||
|
Set $_Z_MAX_SCORE lower to age entries out faster (default
|
||||||
|
9000).
|
||||||
Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
|
Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
|
||||||
Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd your-
|
Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd your-
|
||||||
self.
|
self.
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ Set \fB$_Z_CMD\fR to change the command name (default \fBz\fR).
|
|||||||
Set \fB$_Z_DATA\fR to change the datafile (default \fB$HOME/.z\fR).
|
Set \fB$_Z_DATA\fR to change the datafile (default \fB$HOME/.z\fR).
|
||||||
.RE
|
.RE
|
||||||
.RS
|
.RS
|
||||||
|
Set \fB$_Z_MAX_SCORE\fR lower to age entries out faster (default \fB9000\fR).
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
Set \fB$_Z_NO_RESOLVE_SYMLINKS\fR to prevent symlink resolution.
|
Set \fB$_Z_NO_RESOLVE_SYMLINKS\fR to prevent symlink resolution.
|
||||||
.RE
|
.RE
|
||||||
.RS
|
.RS
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
# * optionally:
|
# * optionally:
|
||||||
# set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
|
# set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
|
||||||
# set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z).
|
# set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z).
|
||||||
|
# set $_Z_MAX_SCORE lower to age entries out faster (default 9000).
|
||||||
# set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
|
# set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
|
||||||
# set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself.
|
# set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself.
|
||||||
# set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
|
# set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
|
||||||
@@ -62,7 +63,8 @@ _z() {
|
|||||||
|
|
||||||
# maintain the data file
|
# maintain the data file
|
||||||
local tempfile="$datafile.$RANDOM"
|
local tempfile="$datafile.$RANDOM"
|
||||||
_z_dirs | awk -v path="$*" -v now="$(date +%s)" -F"|" '
|
local score=${_Z_MAX_SCORE:-9000}
|
||||||
|
_z_dirs | awk -v path="$*" -v now="$(date +%s)" -v score=$score -F"|" '
|
||||||
BEGIN {
|
BEGIN {
|
||||||
rank[path] = 1
|
rank[path] = 1
|
||||||
time[path] = now
|
time[path] = now
|
||||||
@@ -79,7 +81,7 @@ _z() {
|
|||||||
count += $2
|
count += $2
|
||||||
}
|
}
|
||||||
END {
|
END {
|
||||||
if( count > 9000 ) {
|
if( count > score ) {
|
||||||
# aging
|
# aging
|
||||||
for( x in rank ) print x "|" 0.99*rank[x] "|" time[x]
|
for( x in rank ) print x "|" 0.99*rank[x] "|" time[x]
|
||||||
} else for( x in rank ) print x "|" rank[x] "|" time[x]
|
} else for( x in rank ) print x "|" rank[x] "|" time[x]
|
||||||
|
|||||||
Reference in new issue
Block a user