z.1 4.5 KB

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