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