1Z(1) User Commands Z(1)
2
3
4
6 z - jump around
7
9 z [-chlrtx] [regex1 regex2 ... regexn]
10
12 bash, zsh
13
15 Tracks your most used directories, based on 'frecency'.
16
17 After a short learning phase, z will take you to the most 'frecent'
18 directory that matches ALL of the regexes given on the command line, in
19 order.
20
21 For example, z foo bar would match /foo/bar but not /bar/foo.
22
24 -c restrict matches to subdirectories of the current directory
25
26 -h show a brief help message
27
28 -l list only
29
30 -r match by rank only
31
32 -t match by recent access only
33
34 -x remove the current directory from the datafile
35
37 z foo cd to most frecent dir matching foo
38
39 z foo bar cd to most frecent dir matching foo, then bar
40
41 z -r foo cd to highest ranked dir matching foo
42
43 z -t foo cd to most recently accessed dir matching foo
44
45 z -l foo list all dirs matching foo (by frecency)
46
48 Installation:
49 Put something like this in your $HOME/.bashrc or $HOME/.zshrc:
50
51 . /path/to/z.sh
52
53 cd around for a while to build up the db.
54
55 PROFIT!!
56
57 Optionally:
58 Set $_Z_CMD to change the command name (default z).
59 Set $_Z_DATA to change the datafile (default $HOME/.z).
60 Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
61 Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd your‐
62 self.
63 Set $_Z_EXCLUDE_DIRS to an array of directory trees to exclude.
64 Set $_Z_OWNER to allow usage when in 'sudo -s' mode.
65 (These settings should go in .bashrc/.zshrc before the line
66 added above.)
67 Install the provided man page z.1 somewhere like
68 /usr/local/man/man1.
69
70 Aging:
71 The rank of directories maintained by z undergoes aging based on a sim‐
72 ple formula. The rank of each entry is incremented every time it is
73 accessed. When the sum of ranks is over 9000, all ranks are multiplied
74 by 0.99. Entries with a rank lower than 1 are forgotten.
75
76 Frecency:
77 Frecency is a portmanteau of 'recent' and 'frequency'. It is a weighted
78 rank that depends on how often and how recently something occurred. As
79 far as I know, Mozilla came up with the term.
80
81 To z, a directory that has low ranking but has been accessed recently
82 will quickly have higher rank than a directory accessed frequently a
83 long time ago.
84
85 Frecency is determined at runtime.
86
87 Common:
88 When multiple directories match all queries, and they all have a common
89 prefix, z will cd to the shortest matching directory, without regard to
90 priority. This has been in effect, if undocumented, for quite some
91 time, but should probably be configurable or reconsidered.
92
93 Tab Completion:
94 z supports tab completion. After any number of arguments, press TAB to
95 complete on directories that match each argument. Due to limitations of
96 the completion implementations, only the last argument will be com‐
97 pleted in the shell.
98
99 Internally, z decides you've requested a completion if the last argu‐
100 ment passed is an absolute path to an existing directory. This may
101 cause unexpected behavior if the last argument to z begins with /.
102
104 A function _z() is defined.
105
106 The contents of the variable $_Z_CMD is aliased to _z 2>&1. If not set,
107 $_Z_CMD defaults to z.
108
109 The environment variable $_Z_DATA can be used to control the datafile
110 location. If it is not defined, the location defaults to $HOME/.z.
111
112 The environment variable $_Z_NO_RESOLVE_SYMLINKS can be set to prevent
113 resolving of symlinks. If it is not set, symbolic links will be
114 resolved when added to the datafile.
115
116 In bash, z appends a command to the PROMPT_COMMAND environment variable
117 to maintain its database. In zsh, z appends a function _z_precmd to the
118 precmd_functions array.
119
120 The environment variable $_Z_NO_PROMPT_COMMAND can be set if you want
121 to handle PROMPT_COMMAND or precmd yourself.
122
123 The environment variable $_Z_EXCLUDE_DIRS can be set to an array of
124 directory trees to exclude from tracking. $HOME is always excluded.
125 Directories must be full paths without trailing slashes.
126
127 The environment variable $_Z_OWNER can be set to your username, to
128 allow usage of z when your sudo enviroment keeps $HOME set.
129
131 Data is stored in $HOME/.z. This can be overridden by setting the
132 $_Z_DATA environment variable. When initialized, z will raise an error
133 if this path is a directory, and not function correctly.
134
135 A man page (z.1) is provided.
136
138 regex(7), pushd, popd, autojump, cdargs
139
140 Please file bugs at https://github.com/rupa/z/
141
142
143
144z January 2013 Z(1)