z.1 5.0 KB

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