z.1 4.8 KB

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