Updated z version

Closes #3248
Closes #4570
parent e44aa503
...@@ -6,7 +6,7 @@ NAME ...@@ -6,7 +6,7 @@ NAME
z - jump around z - jump around
SYNOPSIS SYNOPSIS
z [-chlrt] [regex1 regex2 ... regexn] z [-chlrtx] [regex1 regex2 ... regexn]
AVAILABILITY AVAILABILITY
bash, zsh bash, zsh
...@@ -15,10 +15,13 @@ DESCRIPTION ...@@ -15,10 +15,13 @@ DESCRIPTION
Tracks your most used directories, based on 'frecency'. Tracks your most used directories, based on 'frecency'.
After a short learning phase, z will take you to the most 'frecent' After a short learning phase, z will take you to the most 'frecent'
directory that matches ALL of the regexes given on the command line. directory that matches ALL of the regexes given on the command line, in
order.
For example, z foo bar would match /foo/bar but not /bar/foo.
OPTIONS OPTIONS
-c restrict matches to subdirectories of the current directory. -c restrict matches to subdirectories of the current directory
-h show a brief help message -h show a brief help message
...@@ -28,10 +31,12 @@ OPTIONS ...@@ -28,10 +31,12 @@ OPTIONS
-t match by recent access only -t match by recent access only
-x remove the current directory from the datafile
EXAMPLES EXAMPLES
z foo cd to most frecent dir matching foo z foo cd to most frecent dir matching foo
z foo bar cd to most frecent dir matching foo and bar z foo bar cd to most frecent dir matching foo, then bar
z -r foo cd to highest ranked dir matching foo z -r foo cd to highest ranked dir matching foo
...@@ -55,8 +60,9 @@ NOTES ...@@ -55,8 +60,9 @@ NOTES
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.
Set $_Z_EXCLUDE_DIRS to an array of directories to exclude. Set $_Z_EXCLUDE_DIRS to an array of directory trees to exclude.
(These settings should go in .bashrc/.zshrc before the lines Set $_Z_OWNER to allow usage when in 'sudo -s' mode.
(These settings should go in .bashrc/.zshrc before the line
added above.) added above.)
Install the provided man page z.1 somewhere like Install the provided man page z.1 somewhere like
/usr/local/man/man1. /usr/local/man/man1.
...@@ -64,12 +70,12 @@ NOTES ...@@ -64,12 +70,12 @@ NOTES
Aging: Aging:
The rank of directories maintained by z undergoes aging based on a sim- The rank of directories maintained by z undergoes aging based on a sim-
ple formula. The rank of each entry is incremented every time it is ple formula. The rank of each entry is incremented every time it is
accessed. When the sum of ranks is greater than 6000, all ranks are accessed. When the sum of ranks is over 9000, all ranks are multiplied
multiplied by 0.99. Entries with a rank lower than 1 are forgotten. by 0.99. Entries with a rank lower than 1 are forgotten.
Frecency: Frecency:
Frecency is a portmantaeu of 'recent' and 'frequency'. It is a weighted Frecency is a portmanteau of 'recent' and 'frequency'. It is a weighted
rank that depends on how often and how recently something occured. As rank that depends on how often and how recently something occurred. As
far as I know, Mozilla came up with the term. far as I know, Mozilla came up with the term.
To z, a directory that has low ranking but has been accessed recently To z, a directory that has low ranking but has been accessed recently
...@@ -107,20 +113,23 @@ ENVIRONMENT ...@@ -107,20 +113,23 @@ ENVIRONMENT
resolving of symlinks. If it is not set, symbolic links will be resolving of symlinks. If it is not set, symbolic links will be
resolved when added to the datafile. resolved when added to the datafile.
In bash, z prepends a command to the PROMPT_COMMAND environment vari- In bash, z appends a command to the PROMPT_COMMAND environment variable
able to maintain its database. In zsh, z appends a function _z_precmd to maintain its database. In zsh, z appends a function _z_precmd to the
to the precmd_functions array. precmd_functions array.
The environment variable $_Z_NO_PROMPT_COMMAND can be set if you want The environment variable $_Z_NO_PROMPT_COMMAND can be set if you want
to handle PROMPT_COMMAND or precmd yourself. to handle PROMPT_COMMAND or precmd yourself.
The environment variable $_Z_EXCLUDE_DIRS can be set to an array of The environment variable $_Z_EXCLUDE_DIRS can be set to an array of
directories to exclude from tracking. $HOME is always excluded. Direc- directory trees to exclude from tracking. $HOME is always excluded.
tories must be full paths without trailing slashes. Directories must be full paths without trailing slashes.
The environment variable $_Z_OWNER can be set to your username, to
allow usage of z when your sudo enviroment keeps $HOME set.
FILES FILES
Data is stored in $HOME/.z. This can be overridden by setting the Data is stored in $HOME/.z. This can be overridden by setting the
$_Z_DATA environment variable. When initialized, z will raise an error $_Z_DATA environment variable. When initialized, z will raise an error
if this path is a directory, and not function correctly. if this path is a directory, and not function correctly.
A man page (z.1) is provided. A man page (z.1) is provided.
......
...@@ -4,7 +4,7 @@ NAME ...@@ -4,7 +4,7 @@ NAME
z \- jump around z \- jump around
.SH .SH
SYNOPSIS SYNOPSIS
z [\-chlrt] [regex1 regex2 ... regexn] z [\-chlrtx] [regex1 regex2 ... regexn]
.SH .SH
AVAILABILITY AVAILABILITY
bash, zsh bash, zsh
...@@ -13,12 +13,14 @@ DESCRIPTION ...@@ -13,12 +13,14 @@ DESCRIPTION
Tracks your most used directories, based on 'frecency'. Tracks your most used directories, based on 'frecency'.
.P .P
After a short learning phase, \fBz\fR will take you to the most 'frecent' After a short learning phase, \fBz\fR will take you to the most 'frecent'
directory that matches ALL of the regexes given on the command line. directory that matches ALL of the regexes given on the command line, in order.
For example, \fBz foo bar\fR would match \fB/foo/bar\fR but not \fB/bar/foo\fR.
.SH .SH
OPTIONS OPTIONS
.TP .TP
\fB\-c\fR \fB\-c\fR
restrict matches to subdirectories of the current directory. restrict matches to subdirectories of the current directory
.TP .TP
\fB\-h\fR \fB\-h\fR
show a brief help message show a brief help message
...@@ -31,13 +33,16 @@ match by rank only ...@@ -31,13 +33,16 @@ match by rank only
.TP .TP
\fB\-t\fR \fB\-t\fR
match by recent access only match by recent access only
.TP
\fB\-x\fR
remove the current directory from the datafile
.SH EXAMPLES .SH EXAMPLES
.TP 14 .TP 14
\fBz foo\fR \fBz foo\fR
cd to most frecent dir matching foo cd to most frecent dir matching foo
.TP 14 .TP 14
\fBz foo bar\fR \fBz foo bar\fR
cd to most frecent dir matching foo and bar cd to most frecent dir matching foo, then bar
.TP 14 .TP 14
\fBz -r foo\fR \fBz -r foo\fR
cd to highest ranked dir matching foo cd to highest ranked dir matching foo
...@@ -76,10 +81,13 @@ Set \fB$_Z_NO_RESOLVE_SYMLINKS\fR to prevent symlink resolution. ...@@ -76,10 +81,13 @@ Set \fB$_Z_NO_RESOLVE_SYMLINKS\fR to prevent symlink resolution.
Set \fB$_Z_NO_PROMPT_COMMAND\fR to handle \fBPROMPT_COMMAND/precmd\fR yourself. Set \fB$_Z_NO_PROMPT_COMMAND\fR to handle \fBPROMPT_COMMAND/precmd\fR yourself.
.RE .RE
.RS .RS
Set \fB$_Z_EXCLUDE_DIRS\fR to an array of directories to exclude. Set \fB$_Z_EXCLUDE_DIRS\fR to an array of directory trees to exclude.
.RE
.RS
Set \fB$_Z_OWNER\fR to allow usage when in 'sudo -s' mode.
.RE .RE
.RS .RS
(These settings should go in .bashrc/.zshrc before the lines added above.) (These settings should go in .bashrc/.zshrc before the line added above.)
.RE .RE
.RS .RS
Install the provided man page \fBz.1\fR somewhere like \fB/usr/local/man/man1\fR. Install the provided man page \fBz.1\fR somewhere like \fB/usr/local/man/man1\fR.
...@@ -88,12 +96,12 @@ Install the provided man page \fBz.1\fR somewhere like \fB/usr/local/man/man1\fR ...@@ -88,12 +96,12 @@ Install the provided man page \fBz.1\fR somewhere like \fB/usr/local/man/man1\fR
Aging: Aging:
The rank of directories maintained by \fBz\fR undergoes aging based on a simple The rank of directories maintained by \fBz\fR undergoes aging based on a simple
formula. The rank of each entry is incremented every time it is accessed. When formula. The rank of each entry is incremented every time it is accessed. When
the sum of ranks is greater than 6000, all ranks are multiplied by 0.99. Entries the sum of ranks is over 9000, all ranks are multiplied by 0.99. Entries with a
with a rank lower than 1 are forgotten. rank lower than 1 are forgotten.
.SS .SS
Frecency: Frecency:
Frecency is a portmantaeu of 'recent' and 'frequency'. It is a weighted rank Frecency is a portmanteau of 'recent' and 'frequency'. It is a weighted rank
that depends on how often and how recently something occured. As far as I that depends on how often and how recently something occurred. As far as I
know, Mozilla came up with the term. know, Mozilla came up with the term.
.P .P
To \fBz\fR, a directory that has low ranking but has been accessed recently To \fBz\fR, a directory that has low ranking but has been accessed recently
...@@ -131,7 +139,7 @@ The environment variable \fB$_Z_NO_RESOLVE_SYMLINKS\fR can be set to prevent ...@@ -131,7 +139,7 @@ The environment variable \fB$_Z_NO_RESOLVE_SYMLINKS\fR can be set to prevent
resolving of symlinks. If it is not set, symbolic links will be resolved when resolving of symlinks. If it is not set, symbolic links will be resolved when
added to the datafile. added to the datafile.
.P .P
In bash, \fBz\fR prepends a command to the \fBPROMPT_COMMAND\fR environment In bash, \fBz\fR appends a command to the \fBPROMPT_COMMAND\fR environment
variable to maintain its database. In zsh, \fBz\fR appends a function variable to maintain its database. In zsh, \fBz\fR appends a function
\fB_z_precmd\fR to the \fBprecmd_functions\fR array. \fB_z_precmd\fR to the \fBprecmd_functions\fR array.
.P .P
...@@ -139,8 +147,11 @@ The environment variable \fB$_Z_NO_PROMPT_COMMAND\fR can be set if you want to ...@@ -139,8 +147,11 @@ The environment variable \fB$_Z_NO_PROMPT_COMMAND\fR can be set if you want to
handle \fBPROMPT_COMMAND\fR or \fBprecmd\fR yourself. handle \fBPROMPT_COMMAND\fR or \fBprecmd\fR yourself.
.P .P
The environment variable \fB$_Z_EXCLUDE_DIRS\fR can be set to an array of 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. directory trees to exclude from tracking. \fB$HOME\fR is always excluded.
Directories must be full paths without trailing slashes. Directories must be full paths without trailing slashes.
.P
The environment variable \fB$_Z_OWNER\fR can be set to your username, to
allow usage of \fBz\fR when your sudo enviroment keeps \fB$HOME\fR set.
.SH .SH
FILES FILES
Data is stored in \fB$HOME/.z\fR. This can be overridden by setting the Data is stored in \fB$HOME/.z\fR. This can be overridden by setting the
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment