README 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. Z(1) User Commands Z(1)
  2. NAME
  3. z - jump around
  4. SYNOPSIS
  5. z [-chlrt] [regex1 regex2 ... regexn]
  6. AVAILABILITY
  7. bash, zsh
  8. DESCRIPTION
  9. Tracks your most used directories, based on 'frecency'.
  10. After a short learning phase, z will take you to the most 'frecent'
  11. directory that matches ALL of the regexes given on the command line.
  12. OPTIONS
  13. -c restrict matches to subdirectories of the current directory.
  14. -h show a brief help message
  15. -l list only
  16. -r match by rank only
  17. -t match by recent access only
  18. EXAMPLES
  19. z foo cd to most frecent dir matching foo
  20. z foo bar cd to most frecent dir matching foo and bar
  21. z -r foo cd to highest ranked dir matching foo
  22. z -t foo cd to most recently accessed dir matching foo
  23. z -l foo list all dirs matching foo (by frecency)
  24. NOTES
  25. Installation:
  26. Put something like this in your $HOME/.bashrc or $HOME/.zshrc:
  27. . /path/to/z.sh
  28. cd around for a while to build up the db.
  29. PROFIT!!
  30. Optionally:
  31. Set $_Z_CMD to change the command name (default z).
  32. Set $_Z_DATA to change the datafile (default $HOME/.z).
  33. Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
  34. Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd your-
  35. self.
  36. Set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
  37. (These settings should go in .bashrc/.zshrc before the lines
  38. added above.)
  39. Install the provided man page z.1 somewhere like
  40. /usr/local/man/man1.
  41. Aging:
  42. The rank of directories maintained by z undergoes aging based on a sim-
  43. ple formula. The rank of each entry is incremented every time it is
  44. accessed. When the sum of ranks is greater than 6000, all ranks are
  45. multiplied by 0.99. Entries with a rank lower than 1 are forgotten.
  46. Frecency:
  47. Frecency is a portmantaeu of 'recent' and 'frequency'. It is a weighted
  48. rank that depends on how often and how recently something occured. As
  49. far as I know, Mozilla came up with the term.
  50. To z, a directory that has low ranking but has been accessed recently
  51. will quickly have higher rank than a directory accessed frequently a
  52. long time ago.
  53. Frecency is determined at runtime.
  54. Common:
  55. When multiple directories match all queries, and they all have a common
  56. prefix, z will cd to the shortest matching directory, without regard to
  57. priority. This has been in effect, if undocumented, for quite some
  58. time, but should probably be configurable or reconsidered.
  59. Tab Completion:
  60. z supports tab completion. After any number of arguments, press TAB to
  61. complete on directories that match each argument. Due to limitations of
  62. the completion implementations, only the last argument will be com-
  63. pleted in the shell.
  64. Internally, z decides you've requested a completion if the last argu-
  65. ment passed is an absolute path to an existing directory. This may
  66. cause unexpected behavior if the last argument to z begins with /.
  67. ENVIRONMENT
  68. A function _z() is defined.
  69. The contents of the variable $_Z_CMD is aliased to _z 2>&1. If not set,
  70. $_Z_CMD defaults to z.
  71. The environment variable $_Z_DATA can be used to control the datafile
  72. location. If it is not defined, the location defaults to $HOME/.z.
  73. The environment variable $_Z_NO_RESOLVE_SYMLINKS can be set to prevent
  74. resolving of symlinks. If it is not set, symbolic links will be
  75. resolved when added to the datafile.
  76. In bash, z prepends a command to the PROMPT_COMMAND environment vari-
  77. able to maintain its database. In zsh, z appends a function _z_precmd
  78. to the precmd_functions array.
  79. The environment variable $_Z_NO_PROMPT_COMMAND can be set if you want
  80. to handle PROMPT_COMMAND or precmd yourself.
  81. The environment variable $_Z_EXCLUDE_DIRS can be set to an array of
  82. directories to exclude from tracking. $HOME is always excluded. Direc-
  83. tories must be full paths without trailing slashes.
  84. FILES
  85. Data is stored in $HOME/.z. This can be overridden by setting the
  86. $_Z_DATA environment variable. When initialized, z will raise an error
  87. if this path is a directory, and not function correctly.
  88. A man page (z.1) is provided.
  89. SEE ALSO
  90. regex(7), pushd, popd, autojump, cdargs
  91. Please file bugs at https://github.com/rupa/z/
  92. z January 2013 Z(1)